This is easiest done by building a server to handle a single client, making sure that the part that handles the client is isolated from everything else. Then expand it to a multiple client structure. It is vital that you properly terminate the child processes, and that requires that the child exit AND THAT THE PARENT PERFORM A WAIT SO THAT THE CHILD PROCESS IS COMPLETELY REMOVED. This is described in the Unix Network Programming Manual, but is often overlooked by beginners.
The server you create is going to do what Program 3 did in providing clients
with a random number fetch capability. There are no special modifications
needed
for this type of service to multiple clients, since each is completely
independent of the other. This will not always be the case.
When creating your server, have it output data on every new client connection,
reporting the address of the client and the port being used. The getsockname
call applied to the socket returned by the accept statement can be used to
get this information.
Get this part going before attempting Part B.
Run your server and at least three clients. Turn in a script of the output from the clients and servers along with the source code.