It is common for networked programs to need to translate text-based representatives of an address or hostname into an address structure required by the socket programming API. The common function we've been using is getaddrinfo(). It is a useful function because it is highly portable (available on Windows, Linux, and macOS), and it works for both IPv4 and IPv6 addresses.
It is also common to need to convert a binary address back into a text format. We use getnameinfo() for this.