Created
February 16, 2020 12:45
-
-
Save ImanMousavi/a22371e830352eb5ff9cc38ea71bf104 to your computer and use it in GitHub Desktop.
check network port in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test if an [ip:port] is open | |
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