Next: Restarting the Route-Engine
Up: Forking & Threading
Previous: Forking & Threading
  Contents
Algorithm for Forking Server
The algorithm for the server is as follows:
- Sockets for end-user (both TCP and UDP) and administrative connections are created and added to the select list.
- Use select to listen for activity on the sockets.
- When a connection request is made, determine which socket it is on, and accept the connection.
- Call fork to create a new process, identical to the first, except for the return value of the call.
- 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.
- 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