socket.error: [Errno 48] Address already in use

后端 未结 10 2265
小鲜肉
小鲜肉 2020-11-29 14:33

I\'m trying to set up a server with python from mac terminal.

I navigate to folder location an use:

python -m SimpleHTTPServer

Bu

10条回答
  •  [愿得一人]
    2020-11-29 14:53

    I am new to Python, but after my brief research I found out that this is typical of sockets being binded. It just so happens that the socket is still being used and you may have to wait to use it. Or, you can just add:

    tcpSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    

    This should make the port available within a shorter time. In my case, it made the port available almost immediately.

提交回复
热议问题