What happens, if the server runs out of ports?

The client connects to the server on the port that it is already listening on. No new port is needed to accept an incoming connection.


A server identifies a TCP connection by the source IP+port of the client. 2 clients can have the same source port as long as their IP addresses are different, so your server will never run out of ports.

If the connection identifier were only the port indeed you could run out of identifiers, because there are only 2^16 ports.

A newer protocol like QUIC uses its own connection identifiers. The IP+port are no longer used as identifiers. The result is that the client can keep using the connection when its IP changes.

Tags:

Port

Socket