python TCPServer address already in use but I close the server and I use `allow_reuse_address`

后端 未结 4 984
渐次进展
渐次进展 2020-12-31 04:35

Here is my code to run the server:

class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    #....

PORT = 8089

httpd = SocketServer.TCPServer(         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 05:12

    It is because you have to set SO_REUSEADDRESS before you bind the socket. As you are creating and binding the socket all in one step and then setting it, it is already too late.

提交回复
热议问题