On Thursday 29 August 2002 3:13 pm, Russ Poffenberger wrote:
In your situation, you would typically have the main thread with a socket listening on a "well known" port for new connections. It would then create a new socket, bind the new socket to that connection, then spawn a new thread to handle just that socket. There really isn't much overhead to a thread, you can have lots of them. The beauty of this is that the main thread doesn't care about the sockets it has spawned off. If the socket connection dies, the thread just terminates. Since the main socket is only listening for connection requests, it doesn't need to manage the other sockets, let the individual threads do that.
This is an awful design for any server that handles lots of connections, there's way too much thread contention to be efficient. - Dale.