![](/img/trans.png)
[英]How do i take picture from client side(html) and save it to server side(Python)
[英]Python : How do server come to know of network failure at the client side?
我正在使用twisted
模块在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()
谢谢
您必须(1)使用读取超时和(2)确保在读取或写入套接字时对所有错误条件做出适当的反应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.