set socket option SO_REUSEADDR to prevent "Address already in use" error

This commit is contained in:
Amir Malik 2010-12-21 10:11:15 +08:00 committed by Joel Martin
parent 40a653f555
commit a22a3cc0ea
1 changed files with 1 additions and 0 deletions

View File

@ -21,6 +21,7 @@ def do_request(connstream, from_addr):
def serve():
bindsocket = socket.socket()
bindsocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
#bindsocket.bind(('localhost', PORT))
bindsocket.bind(('', PORT))
bindsocket.listen(5)