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") |