Skip to content

Instantly share code, notes, and snippets.

@bl-ue
Forked from betrcode/README.md
Created April 11, 2022 23:59
Show Gist options
  • Save bl-ue/82f9664337123200770673d85daa816d to your computer and use it in GitHub Desktop.
Save bl-ue/82f9664337123200770673d85daa816d 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