This chapter contains the description of the Posix.1g getaddrinfo function, along with a complete implementation that supports IPv4, IPv6, and Unix domain sockets. Also provided are six functions (tcp_connect, udp_client, etc.) that call getaddrinfo, which can simplify writing protocol-independent network programs to run under IPv4 and IPv6.