Replace gethostbyname* by getaddr info. The  getaddrinfo()  function  combines  the
functionality  provided  by the getservbyname(3) and getservbyport(3) functions into
a single interface, but unlike the latter functions, getaddrinfo() is reentrant and
allows programs to eliminate IPv4-versus-IPv6 dependencies.