You are here : python_3socketsocketgetaddrinfo

socket.getaddrinfo() - socket

Translate the host/port argument into a sequence of 5-tuples that contain
all the necessary arguments for creating a socket connected to that service.
host is a domain name, a string representation of an IPv4/v6 address
or None. port is a string service name such as 'http', a numeric
port number or None.  By passing None as the value of host
and port, you can pass NULL to the underlying C API.


Syntax

socket.getaddrinfo(host, port, family=0, type=0, proto=0, flags=0)


Example

>>> socket.getaddrinfo("example.org", 80, proto=socket.IPPROTO_TCP)
[(<AddressFamily.AF_INET6: 10>, <SocketType.SOCK_STREAM: 1>,
 6, '', ('2606:2800:220:1:248:1893:25c8:1946', 80, 0, 0)),
 (<AddressFamily.AF_INET: 2>, <SocketType.SOCK_STREAM: 1>,
 6, '', ('93.184.216.34', 80))]


Output / Return Value


Limitations


Alternatives / See Also


Reference