From Fedora Project Wiki
== Domain Name System
=== Resolving using getaddrinfo()
in applications
The getaddrinfo()
function is a dualstack-friendly API to name
resolution. It is used by applications to translate host and
service names to a linked list of struct addrinfo
objects.
And example of getaddrinfo()
call:
int error; struct addrinfo hints; struct addrinfo *result; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = 0; hints.ai_protocol = 0; hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; error = getaddrinfo(node, service, &hints, &result)