Skip to content

Instantly share code, notes, and snippets.

@rihahari
Forked from betrcode/README.md
Created March 6, 2018 08:12
Show Gist options
  • Save rihahari/638bafc2ee7f1c5ae7316dfb6b260556 to your computer and use it in GitHub Desktop.
Save rihahari/638bafc2ee7f1c5ae7316dfb6b260556 to your computer and use it in GitHub Desktop.
Using Python to check if remote port is open and accessible.
import socket
def isOpen(ip,port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, int(port)))
s.shutdown(2)
return True
except:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment