Is res_query thread-safe?
Is res_query (int res_query(const char *dname, int class, int type,unsigned c开发者_运维技巧har *answer,
int anslen);
) thread-safe?
I think so, because it writes its answer to an user-allocated buffer (in contrast to gethostbyname that uses a statically allocated buffer).
Does somebody know for sure?
You were right that res_query is not threadsafe. You have to use res_nquery, which takes a 'res_state' argument first. From everything I've read, that is how the query should be done in a thread safe manner.
精彩评论