Posted By

manatlan on 09/12/09


Tagged

socket python


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vkolev
magna


test if an [ip:port] is open


 / Published in: Python
 

  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  

You need to login to post a comment.