jackailocal / scratch /test_port.py
jackboy70's picture
Deploy: accurate lite-builder note
f25362a
Raw
History Blame Contribute Delete
363 Bytes
import socket
def check_port(host, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
try:
s.connect((host, port))
print(f"Port {port} is OPEN!")
s.close()
return True
except Exception as e:
print(f"Port {port} is CLOSED: {e}")
return False
check_port("127.0.0.1", 7870)