-1
我有一個綁定兩個端口:6961和6963的應用程序。它是一個客戶端控制另一個客戶端的客戶端服務器客戶端的應用程序。服務器守護進程的套接字停止工作
該應用程序運行良好,但在接受和關閉的連接看似隨機的數量後,服務器拒絕通過套接字接收或發送數據。我可以與telnet
建立連接,但是當我鍵入內容時,我不會回覆回覆。
我已經有多次服務器接受多達370個連接,直到它拒絕工作,但上次它只接受70個連接。
我不認爲這與套接字的關閉有關,我認爲這是我正確的做法。當我啓動應用程序時,這是我的netstat
和lsof
輸出。但我還沒有真正知道如何解釋它們。我在Google上搜索時發現了這些。
$ 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
我沒有得到一個想法從哪裏開始尋找錯誤。
無法用lsof和netstat輸出回答,你可能有一個錯誤。把它燒到一個複製器併發布一些代碼。如果你真的有**不知道從哪裏開始,請在[valgrind](http://www.valgrind.org)下運行並修復它抱怨的任何內容。 – 2011-06-05 14:28:00