Answering another question, I stumbled upon the man page of a function called herror
. It appears to be very much like perror
except it prints errors related to some host lookup problem. The man page states that this function is “obsolete”. A function hsterror
which could be used to turn the error number into a string without printing it is marked obsolete as well.
What I don't see is any indication as to why either of them is obsolete, and what replacement should be used instead. So what is the preferred way to turn an obscure h_errno
error number into a user-readable string on a GNU libc linux system? Should every tiny application ship a translation table of its own, and hope that the set of possible error codes doesn't change any time soon?
They are obsolete because
gethostbyname*
is obsolete. Usegetaddrinfo
instead, and usegai_strerror
for errors.From the
gethostbyname(3)
man page: