Advertisement
Guest User

Untitled

a guest
Aug 15th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python    #tells which version of python we are using
  2. import socket   #import sockets
  3. ip = raw_input("Enter the ip: ")   #Asks us to input an ip address eg 127.0.0
  4. port = input("Enter the port: ")   #Asks user to imput a port e.g 80 , 23 , 22 etc
  5. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  6. if s.connect_ex((ip, port)):
  7. print "Port", port, "is closed"  #tells you port is closed
  8. else:  #if no port is open
  9. print "Port", port, "is open"  #port is open
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement