There's many different pieces in play. Since a connection is defined by (Src IP, Src Port, Dest IP, Dest Port)
tuples, you're allowed 65536 ^ 2 connections between two given peers at any given time: from 1 to 1, from 1 to 2, .. from 1 to 65535, etc. And that's just between two peers -- you can of course have many connections open to many peers simultaneously.
BUT, most operating systems limit the number of open filedescriptors / handles per process. This limit was historically low (20), but is now often higher (1024 on my system, ulimit -a
will show per-process limits in bash(1)
).
In addition to the setrlimit(3)
limits on Unix systems, there are also system-wide limits; /proc/sys/fs/file-max
on a Linux system will report the maximum number of open files allowed on the entire system. (This is 596118 on my system.) Other systems will have different limits.
And, there may be a limit to the number of open connections enforced by a stateful firewall in the middle. Since each state requires memory in the firewall tables, any will probably enforce some arbitrary limit to avoid running short on memory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…