Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:06:37+00:00 2026-06-08T07:06:37+00:00

I am trying to make a Javascript (Nodejs) app communicate with a Python app.

  • 0

I am trying to make a Javascript (Nodejs) app communicate with a Python app.

I got something working using a socket bound to my localhost and a specific port.

To make things simpler (e.g., when deploying to environments that may not allow me to listen on multiple ports), I wanted to change my implementation to use a socket bound to a file descriptor.

I searched high and low, but all examples I found use ports.

Basically I need the Python server counter part to this example from the Nodejs docs (the version specifying a path):

var client = net.connect({path: '/tmp/echo.sock'}.

Could someone please provide a simple example showing, creation and binding a file descriptor socket and processing data on it and/or point me in the right direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:06:38+00:00Added an answer on June 8, 2026 at 7:06 am

    I modified the this nice example a bit (e.g., python server has to listen on TCP instead UDP socket to be compatible with nodejs client.

    I’m posting python server and nodejs client code here for reference:

    Python Server:

    import socket
    import os, os.path
    import time
    
    sockfile = "./communicate.sock"
    
    if os.path.exists( sockfile ):
      os.remove( sockfile )
    
    print "Opening socket..."
    
    server = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM )
    server.bind(sockfile)
    server.listen(5)
    
    print "Listening..."
    while True:
      conn, addr = server.accept()
    
      print 'accepted connection'
    
      while True: 
    
        data = conn.recv( 1024 )
        if not data:
            break
        else:
            print "-" * 20
            print data
            if "DONE" == data:
                break
    print "-" * 20
    print "Shutting down..."
    
    server.close()
    os.remove( sockfile )
    
    print "Done"
    

    Nodejs Client:

    Uses npmlog to get colored log output npm install npmlog

    var net = require('net')
      , log = require('npmlog')
      , sockfile = './communicate.sock'
      ;
    
    var client = net.connect( { path: sockfile });
    
    client
      .on('connect', function () {
        log.info('client', 'client connected');
        client.write('hello server');
      })
      .on('data', function (data) {
        log.info('client', 'Data: %s', data.toString());
        client.end(); 
      })
      .on('error', function (err) {
        log.error('client', err);
      })
      .on('end', function () {
        log.info('client', 'client disconnected');
      })
      ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a new spine javascript app using d3 (generated using Spine.app).
I'm trying to make a drop down menu using javascript/jquery but can't get my
I am trying to make an iPhone application for mobile health using HTML5, JavaScript,
I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I am using JavaScript and trying to make a skew effect on a div.
hello im trying to make something like github treeslider im new to javascript.. but
In trying to make my Javascript unobtrusive, I'm using onLoad s to add functionality
I'm trying to make a javascript game and I'm using WebSQL to store game
I have a javascript web app that I am trying to make so you
I am trying to make a Javascript that loops infinitly. function scroll(num) { $(.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.