0

65535 is the maximum number of TCP ports available.
On server side, after accept() a new socket is generated having different address than the server-socket.
Hence, for an HTTP traffic over TCP, a single machine could have a maximum of
(65535 - well_known_ports) socket connections. Is that correct?

Mr.President
  • 163
  • 1
  • 9
  • A single machine can have hundreds of IP addresses, each with tens of thousands of sockets. – Mark Plotnick Mar 12 '20 at 11:25
  • *"after accept() a new socket is generated having different address"* - nope if by "address" you mean "server socket IP+port". What makes you think that? – red0ct Mar 12 '20 at 11:26
  • @red0ct It's from a very reputed university's doc. It says - "You'll note that the address of the new socket is different than the address of the server socket. This make sense. You can't have two sockets communicating on the same port, so when a client connects, the OS must establish a new connection on a different port so not to collide with the server port". Have I misunderstood? – Mr.President Mar 12 '20 at 11:29
  • @MarkPlotnick Thanks, Sir. I forgot virtual servers! – Mr.President Mar 12 '20 at 11:32
  • 3
    Does this answer your question? [How many socket connections possible?](https://stackoverflow.com/questions/651665/how-many-socket-connections-possible), [Number of network connections possible](https://stackoverflow.com/questions/5945695/number-of-network-connections-possible),[What is the theoretical maximum number of open TCP connections that a modern Linux box can have](https://stackoverflow.com/questions/2332741/what-is-the-theoretical-maximum-number-of-open-tcp-connections-that-a-modern-lin). – Steffen Ullrich Mar 12 '20 at 12:41
  • @SteffenUllrich No, Sir. I too went there first, but it mostly answers kind of how to get more and more connections. I was studying a university lecture (pdf), I have quoted that in my 1st comment, and got confused as to how many maximum sockets connections could be for a single machine. I must have mentioned this too in my question - No virtual servers, just a machine with a single IP address. – Mr.President Mar 12 '20 at 12:48
  • @SteffenUllrich Just saw your edit to the comment, reading other posts that i did not earlier. Many thanks. – Mr.President Mar 12 '20 at 12:49
  • @SteffenUllrich This is the answer [What-is-the-theoretical-maximum-number-of-open-tcp-connections-that-a-modern-linus box can have](https://stackoverflow.com/questions/2332741/what-is-the-theoretical-maximum-number-of-open-tcp-connections-that-a-modern-lin) NOT the one that smoky-blue box refers to, hence leaving it as it is. – Mr.President Mar 12 '20 at 12:59
  • 1
    *"very reputed university's doc"* - tell us what's a great University? | *"address of the new socket is different than the address of the server socket"* - what's the thesaurus? Does 'server socket' mean 'listening socket' and 'new socket' mean the 'accepted' one? – red0ct Mar 12 '20 at 16:11
  • 1
    Seems that you are you're mixing things up. In title you are talking about number of sockets, but in content you talk about the number of "socket connections". It's absolutely unclear. Please determine the terms first. – red0ct Mar 12 '20 at 16:25
  • @red0ct Editing the title, during this entire time I was talking only about socket-connections. – Mr.President Mar 13 '20 at 12:43

1 Answers1

1

The connection is identified by Source address, Destination Address, Source port, Destination port. So if you fix the destination port to 80 (HTTP), the destination address to your server IP and the source address to your client IP, then, yes the number of contemporaneous connections cannot exceed the number of port range.
Theoretically your server can have more connections than the port range if it talks with multiple clients.

narotello
  • 419
  • 2
  • 14
ieio
  • 173
  • 9
  • Thanks for replying, Sir. So, for a single machine with a single IP address, the number of connections would be limited by port range. – Mr.President Mar 12 '20 at 13:15
  • 1
    @Mr.President *"single machine"* - which single machine? Are talking about server machine or client machine (in particular mentioned by ieio case with fixed *client's IP* and *server's port + IP*) or some firewall which can be in the middle and track the *connections*? Are you talking about connections or sockets? – red0ct Mar 12 '20 at 16:43
  • 2
    @Mr.President One more time just for outstandingly gifted students of reputed universities: ***Connection*** is represented by ******. So if you talk about connection - bring us that specific context in terms of connection please. – red0ct Mar 12 '20 at 16:49
  • @red0ct Am talking about socket connnections, Sir. – Mr.President Mar 13 '20 at 12:42
  • @red0ct Server as a single machine with a single IP address. No firewall. Also, am not in any university yet, just learning things, please suggest me some links (easy to understand) for understanding sockets in detail. (I basically want to understand how a server deals with concurrent client-connections, what happens when connections exceed...that way I could understand uwsgi settings for server properly) – Mr.President Mar 13 '20 at 13:02