美文网首页Python
python address already in use

python address already in use

作者: 戏之地 | 来源:发表于2017-01-07 14:39 被阅读135次

    在socket中使用

    phone=socket(AF_INET,SOCK_STREAM)
    phone.setsockopt(SOL_SOCKET,SO_REUSEADDR,1) #就是它,在bind前加
    phone.bind(('127.0.0.1',8080))
    

    在socketserver中使用

    # allow_reuse_address should be on the class, not on the instance.
    socketserver.TCPServer.allow_reuse_address = True
    server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
    

    相关文章

      网友评论

        本文标题:python address already in use

        本文链接:https://www.haomeiwen.com/subject/evjfbttx.html