Takes a host name on the command like and prints all resulting matches for it. : Address Info « Network « Python






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

Takes a host name on the command like and prints all resulting matches for it.
import sys, socket

result = socket.getaddrinfo('www.google.com', None, 0, socket.SOCK_STREAM)

counter = 0
for item in result:
    print "%-2d: %s" % (counter, item[4])
    counter += 1


           
       








Related examples in the same category

1.Basic getaddrinfo() basic exampleBasic getaddrinfo() basic example
2.Takes a host name on the command line and prints all resulting matches for it.Takes a host name on the command line and prints all resulting matches for it.