sock-server.py: Use SO_REUSEADDR to avoid errors on quick restart.

This commit is contained in:
Paul Sokolovsky 2014-01-26 02:00:15 +02:00
parent a88c30c64a
commit 4795c58f3c
1 changed files with 1 additions and 0 deletions

View File

@ -16,6 +16,7 @@ ai = socket.getaddrinfo("127.0.0.1", 8080)
print("Bind address info:", ai)
addr = ai[0][4]
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
s.listen(5)
print("Listening, connect your browser to http://127.0.0.1:8080/")