我正在基于此代码实现龙卷风套接字服务器:
https://gist.github.com/robcowie/974695
客户端是Python简单套接字客户端。当我在客户端中调用socket.close()
时,服务器中没有任何反应。我在服务器中放置了完整的print
跟踪,并且没有检测到关闭。
我知道我可以检测到闭包,例如发送字符串“CNNDEND”,这意味着关闭。但我想知道是否有任何方法可以从客户端检测服务器socket.close()
。
答案 0 :(得分:0)
__init__
中的:
self.stream.set_close_callback(self.__onClose)
Connection类中的:
def __onClose(self):
print 'close detected'