1

TCP uses port numbers to identify sending and receiving application end-points on a host, or Internet sockets. Each side of a TCP connection has an associated 16-bit unsigned port number (0-65535) reserved by the sending or receiving application

Now if we want to create tcp connection and keep it alive i cannot go more then 65535

What should be the best strategy to cross the limit 65k?

adding multiple interface can increase the possibility of creating more connection is there any other stategy

3 Answers 3

1

TCP requires that the tuple (server-ip, server-port, client-ip, client-port) is different for each connection. You can change any one of those to get a new connection. A different server-ip is OK, as is a different client-port. The two port ranges alone give you 2^16*2^16 ~ 4 billion connections.

Sign up to request clarification or add additional context in comments.

1 Comment

And if you think about it, if a server only used its own port, it could only ever handle 1 connection at a time, and if it only ever used the client port than it could only handle 64K clients at a time. But popular webservers handle much more traffic than that at a time, so it must be using a combination of multiple values to identify each connection, thus increasing the limits significantly.
1

Each side of a TCP connection has an associated 16-bit unsigned port number (0-65535) reserved by the sending or receiving application

No. (1) It is 1-65535, not 0-65535. (2) Client side ports are usually reserved by the operating system, not by the application. (3) There is no such thing as the 'sending or receiving application'. There are client and server applications.

If we want to create tcp connection and keep it alive i cannot go more then 65535

No again. If you want to create connections in a client you cannot create more than 65535 to the same target. if you want to accept connections in a server you can accept as many as you like, subject to the prior limit at the client end in each client.

What should be the best strategy to cross the limit 65k?

65535 is 64k-1, not 65k, and there really isn't any such limit except as above, which isn't any kind of limit in practice. You don't need 64k client connections to the same target.

1 Comment

Hi. In my case, I need to connect more thatn 65535 clients from single terminal to same target. How can i archive this?
0

Just because a port number is limited to 64K value does not mean you are limited to 64K connections maximum. You can connect to the same port on different servers (think of how many websites you visit at a time, they all listen on port 80 or 443), and you can reuse the same local port for multiple connections as long as they are connected to different servers. It is the combination of [LocalIP:LocalPort]+[RemoteIP:RemotePort] that uniquely identifies a TCP connection, so that gives you flexibility to tweak those values to allow more connections.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.