我正在使用twisted
模块开发基于聊天的Python应用程序。 建立连接一段时间后,让我们假设,客户端的网络连接失败。Python:服务器如何在客户端知道网络故障?
如何确保服务器接收到有关网络故障的通知?
这里是代码片段(服务器程序):
def main():
"""This runs the protocol on port 8000"""
factory = protocol.ServerFactory()
factory.protocol = Echo
PortNo = 8000
reactor.listenTCP(PortNo,factory)
reactor.run()
# this only runs if the module was *not* imported
if __name__ == '__main__':
main()
感谢
当网络出现故障时,不调用connectionLost()事件。乒乓球是我现在正在考虑的一个想法。我不知道如何处理来自服务器端所有客户端的ACK – Kiran