Make sure the machine has at least a few dozen TCP sockets open: dd if=/proc/net/tcp bs=129 -- shows all open TCP sockets dd if=/proc/net/tcp bs=128 -- does not I stumbled across this when I tried to run less on /proc/net/tcp, and got far fewer sockets than I knew I had. After tracking down what was going on, I discovered that if you keep doing a read on /proc/net/tcp with a buffer size of 128 bytes or less, you're going to get a premature EOF indication.
Created attachment 4309 [details] An example
This is an off-by-one error; the patch below fixes it for me. --- linux/net/ipv4/proc.c.org Wed Oct 18 18:27:26 2000 +++ linux/net/ipv4/proc.c Wed Oct 18 19:27:58 2000 @@ -186,7 +186,7 @@ if (req->sk) continue; pos += 128; - if (pos < offset) + if (pos <= offset) continue; get__openreq(sp, req, tmpbuf, i); len += sprintf(buffer+len, "%-127s\n", tmpbuf); @@ -196,7 +196,7 @@ } pos += 128; - if (pos < offset) + if (pos <= offset) goto next; get__sock(sp, tmpbuf, i, format);
Long fixed should have been closed