How do Multiple TCP Clients Connect Simultaneously to a Single Port on a Server?

TCP connections are identified by a server TCP address and port and a client TCP address and port. So, although every connection to a given port will have the server-side TCP address and port in common, they will have different client addresses and/or ports - making each connection unique.

When two clients on the same machine connect to the same server, the OS on that machine will generate distinct TCP port numbers for each connection. It is possible for a client to request a specific TCP port to connect from using the bind() system call; however, if two clients request the same port, only the first request will succeed.

The netstat command shows the four parts of a TCP connection:

netstat -n

Active Connections

  Proto  Local Address          Foreign Address        State

Here we have run netstat on the host where the server is listening on port 5432, and so the server address and port of the connection are shown as Local; the client has connected from a different host with IP address, and so this is shown as Foreign.


Blog: Cloudy with a Chance of TCP Drops
Network Data: Key Concepts
Network Performance Monitoring
Corvil for IT Operations Analytics