title: Is there a way for multiple processes to share a listening socket?
body: <p>In socket programming, you create a listening socket and then for each client that connects, you get a normal stream socket that you can use to handle the client's request. The OS manages the queue of incoming connections behind the scenes.</p>
  
  <p>Two processes cannot bind to the same port at the same time - by default, anyway.</p>
  
  <p>I'm wondering if there's a way (on any well-known OS, especially Windows) to launch multiple instances of a process, such that they all bind to the socket, and so they effectively share the queue. Each process instance could then be single threaded; it would just block when accepting a new connection. When a client connected, one of the idle process instances would accept that client.</p>
  
  <p>This would allow each process to have a very simple, single-threaded implementation, sharing nothing unless through explicit shared memory, and the user would be able to adjust the processing bandwidth by starting more instances.</p>
  
  <p>Does such a feature exist?</p>
  
  <p><strong>Edit:</strong> For those asking "Why not use threads?" Obviously threads are an option. But with multiple threads in a single process, all objects are shareable and great care has to be taken to ensure that objects are either not shared, or are only visible to one thread at a time, or are absolutely immutable, and most popular languages and runtimes lack built-in support for managing this complexity.</p>
  
  <p>By starting a handful of identical worker processes, you would get a concurrent system in which the <em>default</em> is no sharing, making it much easier to build a correct and scalable implementation.</p>