From the man page:
The gethostbyname*() and gethostbyaddr*() functions are obsolete.
Applications should use getaddrinfo(3) and getnameinfo(3) instead.
That's what I did, using the canonical name as a relevant entry, which looks like the closer match to the original call.