eli5: why so many ports?

137 views

“TCP also introduces a concept of a port: each connection has two ports, one for both sides. A port is an integer between 0 and 65535. A server typically waits for a new connection at a well-known port. Default ports for widely-used protocols are well-established and are typically small numbers, for example, HTTP uses port 80. A client also needs its own port. These ports are typically large numbers selected automatically by an operating system, based on what ports are available.”

Why is there a need for so many ports if there is just a client and a server? If there were multiple clients I assume the port number would need to be significantly big, but 65535 is relatively small.

In: 7

6 Answers

Anonymous 0 Comments

You are exactly right. Servers don’t have 1 client usually, they have 100s or 1000s of clients. and sometimes 65535 is a problem. Because you really don’t even have that many, as the bottom 10k are really reserved. So you really only have 55k that you can use for dynamic ports.

The way they do this, is once the communication is done between the client and server, then the port is closed. So the server has the ability to open and close ports rapidly, to hopefully keep from getting that dynamic area full.

Sometimes, you have problems with misconfigured servers that keep the ports open (called keepalive) for too long of a period of time. So they run out of ports quickly. But if servers are configured correctly you actually can handle most load ok.

Many servers can have the problem of port depletion, like database servers, Voice over IP servers, web servers, FTP servers, file servers, etc.

You are viewing 1 out of 6 answers, click here to view all answers.