On Mac OS X El Capitan, I am running a C++ application that calls gethostbyname()
and sometimes passes the argument string matching the current machine:
bash-3.2$ hostname
Ws-MacBook-Pro
This normally works, however, on rare occasions, I get a NULL
result and h_errno
is set to HOST_NOT_FOUND
.
Is this a known issue? How can my application recover from this? I'd like to retry on the hopes it succeeds, but how would I distinguish a real host not found failure from this transient one for the current machine's name? How long would such a failure likely persist and what might be causing it?