test if an [ip:port] is open


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import socket
  2.  
  3. def isOpen(ip,port):
  4. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  5. try:
  6. s.connect((ip, int(port)))
  7. s.shutdown(2)
  8. return True
  9. except:
  10. return False

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.