Set reuse address option (fixes #1043)
When the server is killed there may still be client-sockets connected in the TIME_WAIT state, causing the bind() call to fail. With the REUSEADDR option we can reuse the address immediately unless another process is actually *listening* on the same address. that we want to reuse the address
This commit is contained in:
parent
728a33f5c3
commit
2a73d9f7ee
@ -296,6 +296,7 @@ def get_port(address, port):
|
|||||||
"""
|
"""
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
try:
|
try:
|
||||||
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
s.bind((address, port))
|
s.bind((address, port))
|
||||||
s.listen(-1)
|
s.listen(-1)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
Loading…
Reference in New Issue
Block a user