getaddrinfo() display : IP Address : Network PYTHON TUTORIALS


PYTHON TUTORIALS » Network » IP Address »

 

getaddrinfo() display


import socket, sys
host, port = sys.argv[1:]

results = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)

for result in results:
    if result[0== socket.AF_INET:
        print "Family: AF_INET"
    elif result[0== socket.AF_INET6:
        print "Family: AF_INET6"
    else:
        print "Family:", result[0]

    if result[1== socket.SOCK_STREAM:
        print "Socket Type: SOCK_STREAM"
    elif result[1== socket.SOCK_DGRAM:
        print "Socket Type: SOCK_DGRAM"

    print "Protocol:", result[2]
    print "Canonical Name:", result[3]
    print "Socket Address:", result[4]



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Network
» IP Address