Actually, gethostbyname is obsolete for any usage since ... many years.
Perhaps we should replace it for getaddrinfo/getnameinfo.

Would that solve the problem?