A TCP Echo Server
Now we'll look at a simple TCP server. In contrast to a TCP client, a server does not usually call connect(). Instead, a TCP server follows the following outline:
Create the socket. This is the same as the corresponding step in a client.
Bind the socket to a local address. A client program can let the operating system choose an IP address and port number to use when it calls connect(), but a server must have a well-known address so that clients can rendezvous with it. For this reason it must explicitly associate the socket with a local IP address and port number, a process known as binding. The function that does this is called bind().
Mark the socket as listening. The server calls the listen() function to warn the operating ...