我有一个绑定两个端口的应用程序:6961 和 6963。它是客户端-服务器-客户端形式的应用程序,其中一个客户端控制另一个客户端。
该应用程序运行良好,但在看似随机数量的接受和关闭连接之后,服务器拒绝通过套接字接收或发送数据。我可以与 建立联系telnet
,但是当我输入内容时,我没有得到回复。
我曾经有几次服务器最多接受 370 个连接,直到它拒绝工作,但上次它只接受 70 个连接。
我认为这与关闭套接字无关,我认为我做得很好。这是我启动应用程序时的输出netstat
。lsof
但我真的不知道如何解释它们。我只是在谷歌搜索时发现了这些。
$ sudo /etc/init.d/icontrold restart
Stopping daemon
Starting daemon
$ sudo netstat | grep -E 696[13]
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50005 TIME_WAIT
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50759 ESTABLISHED
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50758 TIME_WAIT
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50764 FIN_WAIT2
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50761 TIME_WAIT
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50763 TIME_WAIT
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50762 TIME_WAIT
$ sudo lsof | grep icontrol
icontrold 5765 root cwd DIR 8,1 4096 884738 /home/ief2
icontrold 5765 root rtd DIR 8,1 4096 2 /
icontrold 5765 root txt REG 8,1 212372 5431298 /usr/sbin/icontrold
icontrold 5765 root mem REG 0,0 0 [heap] (stat: No such file or directory)
icontrold 5765 root mem REG 8,1 77808 5425003 /usr/lib/libz.so.1.2.3
icontrold 5765 root mem REG 8,1 9640 671771 /lib/tls/i686/cmov/libdl-2.4.so
icontrold 5765 root mem REG 8,1 1248904 671768 /lib/tls/i686/cmov/libc-2.4.so
icontrold 5765 root mem REG 8,1 40208 671760 /lib/libgcc_s.so.1
icontrold 5765 root mem REG 8,1 149284 671772 /lib/tls/i686/cmov/libm-2.4.so
icontrold 5765 root mem REG 8,1 888612 5425516 /usr/lib/libstdc++.so.6.0.8
icontrold 5765 root mem REG 8,1 95056 671782 /lib/tls/i686/cmov/libpthread-2.4.so
icontrold 5765 root mem REG 8,1 1268568 5458256 /usr/lib/i686/cmov/libcrypto.so.0.9.8
icontrold 5765 root mem REG 8,1 255648 5458257 /usr/lib/i686/cmov/libssl.so.0.9.8
icontrold 5765 root mem REG 8,1 105112 673124 /lib/ld-2.4.so
icontrold 5765 root 0u IPv6 16962 TCP *:6963 (LISTEN)
icontrold 5765 root 1u IPv6 16965 TCP *:6961 (LISTEN)
icontrold 5765 root 4u IPv6 16968 TCP 192.168.1.10:6963->192.168.1.4:50759 (ESTABLISHED)
$
这是服务器停止接受时两个命令的输出:
$ sudo lsof | grep icontrol
icontrold 4645 root cwd DIR 8,1 4096 7913473 /root
icontrold 4645 root rtd DIR 8,1 4096 2 /
icontrold 4645 root txt REG 8,1 212372 5431298 /usr/sbin/icontrold
icontrold 4645 root mem REG 0,0 0 [heap] (stat: No such file or directory)
icontrold 4645 root mem REG 8,1 77808 5425003 /usr/lib/libz.so.1.2.3
icontrold 4645 root mem REG 8,1 9640 671771 /lib/tls/i686/cmov/libdl-2.4.so
icontrold 4645 root mem REG 8,1 1248904 671768 /lib/tls/i686/cmov/libc-2.4.so
icontrold 4645 root mem REG 8,1 40208 671760 /lib/libgcc_s.so.1
icontrold 4645 root mem REG 8,1 149284 671772 /lib/tls/i686/cmov/libm-2.4.so
icontrold 4645 root mem REG 8,1 888612 5425516 /usr/lib/libstdc++.so.6.0.8
icontrold 4645 root mem REG 8,1 95056 671782 /lib/tls/i686/cmov/libpthread-2.4.so
icontrold 4645 root mem REG 8,1 1268568 5458256 /usr/lib/i686/cmov/libcrypto.so.0.9.8
icontrold 4645 root mem REG 8,1 255648 5458257 /usr/lib/i686/cmov/libssl.so.0.9.8
icontrold 4645 root mem REG 8,1 105112 673124 /lib/ld-2.4.so
icontrold 4645 root 0u IPv6 13679 TCP *:6963 (LISTEN)
icontrold 4645 root 2u IPv6 13683 TCP *:6961 (LISTEN)
icontrold 4645 root 3u IPv6 15276 TCP 192.168.1.10:6963->192.168.1.4:50730 (ESTABLISHED)
icontrold 4645 root 4u IPv6 13685 TCP 192.168.1.10:6963->192.168.1.4:50005 (ESTABLISHED)
$ sudo netstat | grep 6963
tcp6 0 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50005 ESTABLISHED
tcp6 9 0 ::ffff:192.168.1.1:6963 ::ffff:192.168.1.:50730 ESTABLISHED
我不知道从哪里开始寻找错误。