You want to create a TCP server that can simultaneously handle multiple TCP clients.
Every time a new client connects, start a new thread to handle the request.
A single TCP endpoint (IP address and port) can serve multiple connections. In fact, the operating system takes care of most of the work for you. All you need to do is launch a worker object on the server that will handle the connection on a new thread.
For example, consider the basic TCP client and server classes shown in recipe Communicate Using TCP. You can convert the server into a multithreaded server that supports multiple simultaneous connections quite easily. First create a class that will interact with an individual ...