For another example of a client/server for a technical application,
we will create a socket based system that sends data from a physics
simulation server to clients rather than just dummy random value
data. We will use classes from our gravitational acceleration
experiment simulation, discussed in Chapter
9: Physics, to build out simulator.
Such a system could be useful where you want to provide a central
location for a simulation. This could be useful in a situation
where the simulation is especially large and needs resources available
on a particularly powerful machine or is being frequently modified
and updated. Clients could log into the server, which would spin
off a simulator dedicated to that particular client. If the
simulation server existed on a multiprocessor system, then each
simulator might get its own processor.
The Client/Server
Procedure
The figures below illustrate the basic procedure and components
involved in the system:
Another approach to the design of the system would
combine the SimWorker
with the simulation class (SimApplet)
and combine the SimClientWorker
with the SimClient
class. This would reduce the communication lines that must
occur among all of these actors.
However, separating them provides greater modularity
and one could either use the worker classes, or subclasses of
them, with other types of simulators and clients.
The Simulator
For our simulator we use classes developed for the gravitational
acceleration experiment demonstration program in Chapter
9: Physics. Here we split the program and use the experiment
simulation classes for the server side and the analysis code for
the client side. The design follows the aim that the server produces
the data and the client analyzes the data. The modularity provided
by the object oriented design helps with adapting the classes
here, though in some cases new classes had to be developed for
this case.
More Info
The client/server simulation is described further on these pages:
Last update: Dec.11, 2004