Skip to content

Instantly share code, notes, and snippets.

@marjetika
Forked from betrcode/README.md
Created February 28, 2019 03:35
Show Gist options
  • Save marjetika/b1e2d8cf2e495d5069233c9421e78842 to your computer and use it in GitHub Desktop.
Save marjetika/b1e2d8cf2e495d5069233c9421e78842 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