add SO_REUSEADDR option to reuse the port in TIME-WAIT status (#1673)

This commit is contained in:
Zhensheng Yuan authored and GitHub committed 2023-03-31 23:07:01 -07:00
1 parent b0dca720a8
commit 2c12f5f205
1 file changed
+1
+1
View File
@@ -44,6 +44,7 @@ def is_port_open(port: int):
""" """
try: try:
sock = socket.socket() sock = socket.socket()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
_ = sock.bind(("", port)) _ = sock.bind(("", port))
sock.close() sock.close()
return True return True