Skip to content

Instantly share code, notes, and snippets.

@sanesai
Created October 18, 2023 15:26
Show Gist options
  • Save sanesai/77bfc275fda1259386466e9c067854d7 to your computer and use it in GitHub Desktop.
Save sanesai/77bfc275fda1259386466e9c067854d7 to your computer and use it in GitHub Desktop.
Test the connectivity
import socket
def check_conn():
conn_data = [
('xyz.abc.int', '10.20.200.10', 443),
('abc.xyz.int', '10.20.200.12', 8080)
]
for name, host, port in conn_data:
s = socket.socket()
try:
s.settimeout(2)
s.connect((host, port))
except Exception as e:
print(f"ERROR → {name} {host}:{port} → {e}")
s.close()
else:
print(f"OK → {name} {host}:{port}")
s.close()
if __name__ == '__main__':
check_conn()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment