What is a socket?
A socket is a combination of IP address and port number. A connection is identified by a socket pair. This connection is always unique.
Different types of servers
There are 2 types of servers - Concurrent and Iterative
1. Concurrent Servers are those that are able to serve all (most) clients simultaneously and accept more client requests as they come.
2. Iterative Servers are those that process the client requests one by one. They use queues.
How iterative servers work
Server can only accept a connection if it is listening to a port, i.e., open to accept connection. When a client requests service from one port, server serves the request, and stops listening for that duration. Any other incoming client request is added to the queue. Ex- An analogy - ATM.
How concurrent servers work
Suppose a client request arrives at port, server creates a child process, called server child and connects this child server to the client. Now, the main server is not blocked and actively listening. For all other client requests, the server creates child processes for each of them, thereby enabling server to work concurrently.