resolv.h DNS query in Android NDK

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

resolv.h DNS query in Android NDK


I need to use an existing C/C++ library that uses res_query from resolv.h for various DNS queries in an Android app via the NDK.
The library builds and links fine, but res_query always fails, returning -1.

A small sample program with just a call to res_query exhibits the same behavior. I've given the app permission.INTERNET and permission.ACCESS_NETWORK_STATE without success. Calling h_errno from netdb.h shows error code 2. The same code works fine when compiled and run on Linux.

Does resolv.h, which is included in the NDK, not work on Android? I understand that Android has no resolv.conf file by default, but I'd have hoped it would redirect the query internally to Android's system DNS service. I cannot find any documentation anywhere about whether or not it should work like that.

You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit