From: Maxwell Lol on 5 Oct 2009 21:26
Barry Margolin <barmar(a)alum.mit.edu> writes:
> The parent process should be in a loop just calling accept() to get new
> connections on the original listening socket.
> The child processes should just be calling read() and write() on the
> connected socket that was returned by accept(). This is a different
> socket from the original listening socket.
> The OS differentiates them automatically for you.
The OS keeps track of each connection using four pieces of information
Server IP Address
Client IP address
The first three are identical. The client OS uses different ports when
connecting to the same server.
The OS uses this to send the packet to the right process.