Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Testing in production

Ruben de Groot hacktor

🏠
Testing in production
View GitHub Profile
View telnet.py
#!/usr/bin/env python3
import sys
import socket
from contextlib import closing
def check_socket(host, port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(1)
if sock.connect_ex((host, port)) == 0:
print("Port is open")