我有python项目。这个项目正在监听一个端口。这是我的代码:
import socket
conn = None # socket connection
###
# port listener
# @return nothing
###
def listenPort():
global conn
conn = socket.socket()
conn.bind(("", 5555))
conn.listen(5)
运行我的应用程序后,我检查了hercules的端口连接。它工作,但我断开连接,再次连接。完成后5次连接返回错误。我想倾听者必须一直工作。我怎样才能得到我想要的应用程序?提前谢谢!在
编辑
我将只在服务器上运行我的应用程序,我将通过Uptime root侦听器来检查它是否正常工作。在
错误正常:
=>;您将5个连接请求排入队列,第6个请求将导致错误。
您必须接受从侦听队列中删除它的请求并使用它(来自相关post的
accepter = conn.accept()
命令)编辑
这里是一个完整的例子:
相关问题 更多 >
编程相关推荐