Basic getaddrinfo() list example : IP Address « Network « Python Tutorial






import sys, socket

result = socket.getaddrinfo("121.1.1.1", None, 0, socket.SOCK_STREAM)

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








21.8.IP Address
21.8.1.Basic gethostbyaddr() example
21.8.2.Basic getaddrinfo() basic example
21.8.3.Basic getaddrinfo() list example
21.8.4.Perform a reverse lookup on the IP address given on the command line
21.8.5.getaddrinfo() display