Handling multiple clients
Handling multiple clients can be achieved using threads. In this section, we will develop a simple parts server and client applications. The server will use a separate thread to handle each client. This technique is simple to implement, but it will not always be suitable for more demanding applications. We will introduce alternate techniques to multitask in Chapter 7, Network Scalability.
The parts server is implemented in the PartsServer class, and the client is implemented in the PartsClient class. A new instance of a ClientHandler class will be created for each client. This handler will accept requests for the price of a part. The client will send the name of the part to the handler. The handler will look up the price ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access