fork download
  1. import socket
  2.  
  3. srv = [
  4. ("10.20.20.1",1433),
  5. ("10.30.30.2",1521),
  6. ("10.30.30.3",80),
  7. ("10.20.20.4",443)]
  8.  
  9. a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  10.  
  11.  
  12. for location in srv:
  13. result_of_check = a_socket.connect_ex(location)
  14. if result_of_check == 0:
  15. print("Port is open")
  16. else:
  17. print("Port is not open")
  18. a_socket.close()
Success #stdin #stdout 0.02s 9556KB
stdin
Standard input is empty
stdout
Port is not open
Port is not open
Port is not open
Port is not open