Writing a robust server application can be a tricky business. Client requests need to be answered promptly. You may need to deal with more than one client at a time. Clients may disconnect, hang up, stop listening, stop talking, or even die!
One way to deal with these complexities is to separate the server into two parts: one part that provides the server semantics, and a second part that is a framework that handles the connections. This is a lot like simplifying phone traffic in an office by hiring a receptionist. The receptionist handles the mechanics of receiving calls and routing them to the correct office workers. With a receptionist in place, all that you have to do as an office worker is know how to handle the calls.
In this tutorial we'll describe a few possible strategies a receptionist might use, and then show code for two of them. Along the way, we'll come up with a simple client-server protocol to make the code concrete.
The code for this tutorial is in the Tools.h++ Professional examples directory. The code shown in this text is edited from the actual code so that we can concentrate on the details of the communication, and ignore the complexities of the real user interface.
NOTE: Complete code for the examples in this chapter is located in the examples directory created for your installation of Tools.h++ Professional. The "Examples" chapter in Part V, "Resources," describes the location of that directory, or you can check the online build guide for your installation media.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.