Python TCPServer,错误98,地址已在使用中

时间:2012-06-18 03:56:39

标签: python sockets tcpserver

我遇到了错误98,当我杀死正在运行的python TCPServer服务器并尝试重新启动它时,已解决使用问题。

我注意到还有其他article,建议使用sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)或设置TCPServer.allow_reuse_address = True。

但我仍面临同样的问题,还有其他原因吗?

我正在使用RedHat EL 6.2,Python 2.6。

由于

我使用的代码是:

TCPServer.allow_reuse_address = True
TCPServer.__init__(self, (gethostname(), self.SERVER_PORT),scheddRequestHandler) 

这一直让我得到错误98.

但是,如果我改为:

TCPServer.allow_reuse_address = True
TCPServer((gethostname(),self.SERVER_PORT),scheddRequestHandler)

错误消失了。

我不清楚为什么会这样?

0 个答案:

没有答案
相关问题