title: How do I create a Python socket server that listens on a file descriptor?
body: <p>I am trying to make a Javascript (Nodejs) app communicate with a Python app.</p>
  
  <p>I got <a href="https://github.com/thlorenz/readarepo-zip/blob/master/highlight/pygments/server/pygments-service.py" rel="nofollow noreferrer">something working</a> using a socket bound to my localhost and a specific port.</p>
  
  <p>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.</p>
  
  <p>I searched high and low, but all examples I found use ports.</p>
  
  <p>Basically I need the Python server counter part to <a href="http://nodejs.org/api/net.html#net_net_createconnection_options_connectionlistener" rel="nofollow noreferrer">this example from the Nodejs docs</a> (the version specifying a path):</p>
  
  <p><code>var client = net.connect({path: '/tmp/echo.sock'}</code>.</p>
  
  <p>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?</p>