开发者

Is res_query thread-safe?

开发者 https://www.devze.com 2023-01-12 13:37 出处:网络
Is res_query (int res_query(const char *dname, int class, int type,unsigned c开发者_运维技巧har *answer,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消