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?
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:
Nodejs Client:
Uses npmlog to get colored log output
npm install npmlog