Socket and Port in TCP

A unique connection is a combination of 5 things that are TCP protocol, Source IP, Source Port, Destination IP and Destination Port; in short called a Tuple.

A TCP listens on ONE port and communicate on that same port. If the client (Source IP) wants to make different TCP connections to a server; the client must generate Random source Ports so that the server can identify them as different connections!

The maximum number of concurrent TCP connections that a server can handle is 64K per client per server port.
Ie. Multiple client server connections means that ONLY the Client Port (‘source port’) varies to differentiate the different connections; Server IP, Server Port and Client IP remains the same.
Ports are allocated in 16-bit numbers, so the maximum number of connections for any given client to server is 64K.

Now, In a scenario of multiple clients; each clients can have up to 64K connections to the Server port, and if the Server has multiple Ports then we can multiply this number.

So, in short, the maximum possible concurrent connections from ONE Source IP and Port to ONE Destination IP and Port is 64K connections!

Socket connection is assigned to a file descriptor, so the real limit is the maximum number of file descriptors configured (typically above 300K, configurable with sysctl.

Server can queue (5-10) the connections in its back log until the present request is processed and served. So the Connection request which is accepted are called open connections (it just means SYN, ACK is send back). If the Server identifies that there are no more file descriptors available to be the allocated for the socket then it fails the accept call and the TCP connection will send a FIN to client side.