PyDocs

Nav

Networking and Interprocess Communication

getaddrinfo

socket

function (source) not WASI
  • getaddrinfo(host, port, family=AF_UNSPEC, type=0, proto=0, flags=0)
Resolve host and port into list of address info entries.

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.

The family, type and proto arguments can be optionally specified in order to
narrow the list of addresses returned. Passing zero as a value for each of
these arguments selects the full range of results.
Changed in 3.2, 3.7
  • 3.2: parameters can now be passed using keyword arguments.
  • 3.7: for IPv6 multicast addresses, string representing an address will not contain %scope_id part.
1 Example
>>> socket.getaddrinfo("example.org", 80, proto=socket.IPPROTO_TCP)
[(socket.AF_INET6, socket.SOCK_STREAM,
 6, '', ('2606:2800:220:1:248:1893:25c8:1946', 80, 0, 0)),
 (socket.AF_INET, socket.SOCK_STREAM,
 6, '', ('93.184.216.34', 80))]
from the Python docs
See Also
No see-alsos for socket/getaddrinfo
0 Notes
No notes for getaddrinfo