Servers need to accommodate multiple, concurrent
requests.
Servers usually have two parts:
- Single master which accepts new requests.
- Multiple slaves (child processes) which handle those requests.
- (1 request = 1 slave)
Steps taken by a Master Server:
- Opens a well-known port (socket open and bind).
- Waits for a new client's request (socket listen).
- Chooses a new local port for the client to connect over.
- Spawns new concurrent slave to service the client over
the new port (socket accept).
- Goes back to waiting for requests while slave processes handle the requests.
Servers are usually more difficult to build than clients since servers must:
- Handle concurrent requests.
- Enforce all access and protection policies of the computer system on which they run.
- Must protect themselves against all possible errors, such as malformed requests and requests causing it to abort.