How many tcp chains on different ports can a server handle?

I am creating a server client application in C #. the client connects and interacts with the server, discarding the tcp socket.

on the server side, I use the socket.accept () method to handle a new connection to the client. when a client connects, the server uses a random port to communicate with the client.

so my question is: how many clients can a server get in this form? is there any other form that i have to use to handle many clients?

+1
c # sockets network-programming
Apr 08 '14 at
source share
3 answers

on the server side, I use the socket.accept () method to handle a new connection to the client. when a client connects, the server uses a random port to communicate with the client.

No, unless you open another, meaningless connection from the server to the client, and you will not do this for the reasons of the firewall. The received socket uses the same local port number as the listening socket. Contrary to a few answers and comments here.

Therefore, your question is based on a misconception. No matter what you run out of, and it can be memory, stream handles, socket handles, socket buffer space, processors, processor power, virtual memory, disk space ... these will not be TCP ports.

EDIT Proponents of the new random port theory should explain the following netstat conclusion:

 TCP 127.0.0.4:8009 0.0.0.0:0 LISTENING TCP 127.0.0.4:8009 127.0.0.1:53777 ESTABLISHED TCP 127.0.0.4:8009 127.0.0.1:53793 ESTABLISHED TCP 127.0.0.4:8009 127.0.0.1:53794 ESTABLISHED TCP 127.0.0.4:8009 127.0.0.1:53795 ESTABLISHED TCP 127.0.0.4:8009 127.0.0.1:53796 ESTABLISHED TCP 127.0.0.4:8009 127.0.0.1:53798 ESTABLISHED TCP 127.0.0.4:8009 127.0.0.1:53935 ESTABLISHED 

and show where RFC 793 talks about placing a new port in the received socket and where in the TCP connect-handshake TCP connection exchange, the new port number is transmitted.

+1
Apr 10
source share
โ€” -

This is practically limited by the OS. You have to check it out. On Windows, you must use a fully asynchronous I / O socket on this scale. You will probably be limited by memory usage.

At the TCP level, there is no practical limit. For each combination (server port, server ip, client port, client ip) can be one connection. Thus, with one server port and one ip server, you can serve an unlimited number of clients if they have less than 65 thousand connections per client.

You do not need to select a random port on the server. This is a common misconception.

+3
Apr 08 '14 at 11:29
source share

You may like this question, which I asked in the same vein: https://softwareengineering.stackexchange.com/questions/234672/is-there-are-problem-holding-large-numbers-of-open-socket-connections- for-length , and especially some of the comments.

The answer seems to be that there is no practical limit. The combination of the receive port and the send port must be unique, and each of them can have values โ€‹โ€‹of 64 KB. The total number of combinations is extremely large. There really are servers with an extremely large number of open connections, but to get there, you need to solve a number of other interesting problems. The question above contains a link to an article on the millionth connection server. See Also How to save one million concurrent TCP connections? . And do an online search of the C10K problem.

What you probably can't do is use synchronous ports and threads, because you are implementing thread restrictions, not port restrictions. You must use asynchronous ports and thread pool. And you will have to write one to throw it away, just to find out how to do it.

-one
Apr 08 '14 at 11:27
source share



All Articles