Mega Code Archive

 
Categories / Python / Network
 

Takes a host name on the command line and prints all resulting matches for it

import sys, socket result = socket.getaddrinfo("www.google.com", None) counter = 0 for item in result:     print "%-2d: %s" % (counter, item[4])     counter += 1