Description of the program:
The program implements the prototype of client-dispatcher-concurrent server
using TCP/IP.
The dispatcher is implented as an iterative server, which serves both
servers and clients. It listens to a single port. It receives information from a
server after the server is set up and stores the sever information into
corresponding list accord ing to the service the server offers. It will delete
the server information after it received the exit information from that server.
It receives client request for some specific service. If the service is
available at some server, the dispatcher then send s the information of that
server to that client. The server pickup is in Round-Robin rotation.
A server is implemented as a concurrent server. When it is set up, it
first sends its information (IP address, port number and service available on
this server) to dispatcher. After that, it listens at its well-known port to
serve the client servic e request. When a client service request is accepted,
the server will fork a child server to serve this client. The server itself will
keep listening on its well-known port. After the child server finished its job,
it will exit. The parent server then han dles SIGCHLD, avoiding zombie process.
A client first contacts the dispatcher. If the connection to the dispathcer fails, the client retries upto 15 times after a certain delay time. The delay time is initially 30 seconds. Upon each retry, the delay is doubled. If the connection to disp atcher is established, the client will send its service request to the dispatcher, and the client will get some information back from the dispatcher. If the service is available on some server, the information is the IP address and port number of that ser ver; if the service is not available, the client will retry to contact the dispatcher for 15 times after certain delay time. After having the information of the sever, the client will contact the server to access the remote procedure. If the connection to server fails, the client will exit.
How to compile the program?
prompt>make
How to execute the program?
1.Set up the dispatcher on willy,
nova or mimi. The dispatcher will alway listen on the port 3498.
prompt>dispatcher
2.Set up servers on willy, nova or
mimi. There can be only one server on each machine. The well-known port is 9003.
prompt>server 132.206.51.205 3498
The
comand line parameters are the IP address of the dispatcher(depends on which
machine it stays on) and the well-known port number of the dispatcher
3498.
3.Set up clients on willy, nova or mimi. There can be any number of
clients on each machine.
prompt>client 132.206.51.205
3498
The comand line parameters are the same as the
server's.
Note: The setup may not follow the above order. If then,
the client will not be served until the dispatcher and the server, which has the
service the client needs, are set up. Some corresponding message will be given
to the client.