resolv.h DNS query in Android NDK

223 views
Skip to first unread message

woalk

unread,
Aug 19, 2020, 10:21:18 AM8/19/20
to android-ndk
Hello,

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.
Reply all
Reply to author
Forward
0 new messages