getaddrinfo

term

programmingnetworking

Kept in this browser · My desk

The socket API's resolver function: it turns a host name or address and a service name or port into the arguments needed to create and connect a socket, for IPv4 and IPv6 alike.

RFC 3493 defines it for protocol-independent translation of names and services. It returns a list of entries, each with an address family, a socket type, a protocol and a socket address; most Linux configurations return the list sorted, and a client should try the entries in order until one connects, or in parallel as Happy Eyeballs does. The AI_NUMERICHOST flag forbids name lookups and accepts numeric addresses only. Python's socket.getaddrinfo() wraps the C function and returns 5-tuples (family, type, proto, canonname, sockaddr).

Also known as: getaddrinfo(), socket.getaddrinfo, AI_NUMERICHOST, addrinfo

← Back to G Back to the glossary