Administrator
12 分钟以前 2f2516749615da866e96d8d24e499b7ecbb63a3e
utils/socket_util.py
@@ -82,9 +82,11 @@
# 端口是否被占用
def is_port_bind(port):
def is_port_bind(port, timeout=1):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(timeout)
    result = sock.connect_ex(('127.0.0.1', port))
    sock.close()
    if result == 0:
        return True
    else:
@@ -92,4 +94,4 @@
if __name__ == "__main__":
    pass
    print(is_port_bind(9004))