-
-
Save dirkakrid/ecb4e383224943cb92e64b52519e4f48 to your computer and use it in GitHub Desktop.
TCPing
This file contains hidden or 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
def ping(server, port): | |
''' Check if a server accepts connections on a specific TCP port ''' | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((server, port)) | |
s.close() | |
return True | |
except socket.error: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment