O'Reilly logo

Learning Network Programming with Java by Richard M Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required