From: Fengfeng Li Date: 2011-11-10T18:50:38+09:00 Subject: How to kill an exist tcpserver or tcpsocket? Hi everyone, I’m using the following codes to create and close a tcpsocket on WindowsXP: def open @tcp_server = TCPServer.new(@para[:host], @para[:port]) @ch = @tcp_server.accept end ... def close @tcp_server.close @ch.close end They are very simple. My problem is, if I don't close()(sometimes my users terminate my programe anyway before close() is called), the TcpServer will be LISTENING and the tcpSocket will be CLOSE_WAIT. If I call open() at this moment, ruby will raise Errno::EADDRINUSE. So, I want to rescue this Exception and handle it, is there a way to kill existed tcpServer/tcpSocket? I searched for a long time, and only found apps like killtcp.exe/aoi.exe, but they would be the last choice to me. Is there some other way? Such as command line or ready-made methods? Thanks a lot. Regards, LiFengfeng -- Posted via http://www.ruby-forum.com/.