Fix addr reuse in check_port (#253)
This commit is contained in:
@@ -103,6 +103,7 @@ def alloc_usable_network_port(num, used_list=()):
|
|||||||
def check_port(port):
|
def check_port(port):
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||||
try:
|
try:
|
||||||
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
s.bind(("", port))
|
s.bind(("", port))
|
||||||
return True
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
|||||||
Reference in New Issue
Block a user