Calculate maximum concurrent socket connections supportable by system file descriptor limits.
A system's total socket footprint spans several distinct kernel-tracked states and families: actively transferring TCP connections (ESTABLISHED), recently closed TCP connections still holding their port reserved (TIME_WAIT), connectionless UDP sockets, and local-only Unix domain sockets used for IPC. Summing these gives the total socket-table pressure a host is under, which matters for both file-descriptor budgeting and kernel memory (each socket carries buffer overhead) — a high TIME_WAIT share in particular often signals a high connection-churn workload that could benefit from connection reuse or tuned tcp_tw_reuse.
Total socket count
total = tcp_established + tcp_time_wait + udp + unix
`ss -tan state established | wc -l`, `ss -tan state time-wait | wc -l`, `ss -uan | wc -l`, and `ss -xan | wc -l` give established TCP, TIME_WAIT TCP, UDP, and Unix socket counts respectively (subtract 1 from each for the header line if using `ss` without `-H`).
Each TIME_WAIT socket holds a local port tied up for 2×MSL (commonly ~60s on Linux) after close, and under very high connection churn this can exhaust the ephemeral port range or add measurable kernel memory overhead — tunable via `net.ipv4.tcp_tw_reuse` and shortened FIN timeouts, though outright disabling TIME_WAIT is not recommended as it protects against delayed duplicate segments.
Yes — all socket types share the same per-process file descriptor budget (ulimit -n) and contribute to overall kernel socket-buffer memory, even though Unix domain sockets never touch the network stack or consume ephemeral ports.