Building on the Web server ideas in Chapter
14, this chapter develops a prototype Data Monitoring Client/Server
system using sockets. Later in Chapter
16-21: Distributed Computing we will discuss more elaborate
client-sever systems using RMI and CORBA.)
As discussed in Chapter 14, a Web server gets a request from a
browser or custom client program, returns the appropriate web page
and then breaks the connection ends.. However, the client/server
systems discussed in this chapter will instead maintain a connection
indefinitely rather than breaking it off as with the web server.
A client session begins with a log-in procedure for the client
with the server. Then the server and client set up I/O streams for
their communications. As in Chapter 14, multiple clients can connect
to the server because it can create a new thread for each new client.
For the log-in, for the exchange of commands, and for the transmission
of data, the two programs need a simple protocol so that
they can understand one another.
To demonstrate the benefits of such a system, we will create server
programs that sends simulated data to clients. We will also create
client programs that display the data obtained from the server.
The client will provide a graphical interface that lets a user request
updated info from the server.
You can easily imagine applications where such a system would be
very useful. For example, it could apply to a server running on
a system that monitors and even controls an experiment or a sensor
in a remote location. Using the client programs, someone could log
in from anywhere on the web to check the data, apply new settings,
etc. The log-in procedure would allow for secure access to the server.
Last update: Dec. 10, 2004
|