gethostbyname once failed never success

424 Views Asked by At

When I call gethostbyname in a NDK application without networking, then I turn on wifi switch, and call gethostbyname with the same host again, and it still failed, h_errno = 2.

Why is this and how to avoid it.

1

There are 1 best solutions below

0
On

As per the returned h_error value, it indicates "TRY_AGAIN". From gethostbyname() man page:

     TRY_AGAIN
      A temporary error occurred on an authoritative name server.Try again later.

So, try again and see what happens.