Skip to content

Instantly share code, notes, and snippets.

@vdchuyen
Created June 8, 2016 09:53
Show Gist options
  • Save vdchuyen/fac4e15b83d790e2537f928dc238bbae to your computer and use it in GitHub Desktop.
Save vdchuyen/fac4e15b83d790e2537f928dc238bbae to your computer and use it in GitHub Desktop.
import socket
import time
s = socket.socket()
address = 'hostname.com'
port = 443
try:
s.connect((address, port))
print(time.asctime() + " OK")
except Exception as e:
print("Oops %s:%d. Can not connect %s" % (address, port, e))
finally:
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment