next up previous contents
Next: Restarting the Route-Engine Up: Forking & Threading Previous: Forking & Threading   Contents


Algorithm for Forking Server

The algorithm for the server is as follows:
  1. Sockets for end-user (both TCP and UDP) and administrative connections are created and added to the select list.
  2. Use select to listen for activity on the sockets.
  3. When a connection request is made, determine which socket it is on, and accept the connection.
  4. Call fork to create a new process, identical to the first, except for the return value of the call.
  5. If the process is the original one, close the socket to the client. If the process is the child, close the server socket and run the code to deal with that particular client.
  6. When communication is finished with a client, the child process can exit. The server process is available all the time, apart from the short moment whilst fork is called.




2000-10-20