Skip to content

Instantly share code, notes, and snippets.

@teezzan
Forked from betrcode/README.md
Created October 16, 2021 06:15
Show Gist options
  • Save teezzan/ff4cb111362deed83ee290df1ebb30bf to your computer and use it in GitHub Desktop.
Save teezzan/ff4cb111362deed83ee290df1ebb30bf 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