If the client joins to a server, then there is a local port, and a remote port in each connection. What happens, if more than 65535 client tries to join to my server?

  • 1
    You will almost certainly run out of file handles before you hit a limit of port counts. Your system might also have limits related to firewall state tracking. But I suspect It would be somewhat protocol/application dependent. – Zoredache Jun 20 '13 at 7:35

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.

  • 3
    You are assuming a simple TCP protocol like http/ssh here. Some protocols, like FTP, will open a port per connection. – Zoredache Jun 20 '13 at 7:33
  • 4
    @Zoredache: It is unhelpful to give an overly complex answer to an extremely simple question. There is a common misunderstanding about how ports are assigned and giving a complex answer will likely just help the misunderstanding persist. – David Schwartz Jun 20 '13 at 7:34

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.