We show here the essential steps involved in our data client/server
system:
We start the DataServer
and it sits patiently waiting for clients to arrive. The client
starts on another machine (or on the same machine for convenience
during testing ) and connects to the server using the socket type
connection discussed in Chapter
14:
Diagram 1: Client connects to a server via its server socket.
A simple log-in in procedure occurs in which the server requests
that the client send a username. The client responds with
a arbitrary name string. You could easily expand this capability
to include both a username and password:
Diagram 2: Client & server execute
a login procedure..
Another client could also simultaneously request a connection
to the server with the same procedure:
Diagram 3: Another client connects to the
server.
The server assigns an instance of the Thread
subclass called DataWorker
whose job is to communicate with a particular client over the
socket and to perform the requested tasks.
Similarly, the client creates an instance ofof the Thread
subclass
DataClientWorker to carry out communications with the
server.
Diagram 5: To provide for remote monitoring
of an experiment, a sensor, or other system,
the
DataWorker
class could obtain information from a disk file, run an external
program
and read its output, communicate with a sensor via a serial port
(see
Chapter 23), or use other
techniques.
Figure 15.5 illustrates other data taking scenarios
such as reading data from an instrument over a serial or parallel
port. It could also run an external program and read its output.
In Chapter 23 we will discuss
how Java programs can reach out to the external world outside
of the JVM.
Latest update: Dec. 10, 2004