check remote port is open or not using python

Solutions on MaxInterview for check remote port is open or not using python by the best coders in the world

showing results for - "check remote port is open or not using python"
Nolan
15 Sep 2019
1
2def port_check(HOST):
3   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4   try:
5      s.connect((HOST, int(22)))
6      s.shutdown(2)
7      return True
8   except:
9      return False