res_query 是线程安全的吗?
是 res_query (int res_query(const char *dname, int class, int type,unsigned char *answer, int anslen);
) 线程安全?
我认为是的,因为它将其答案写入用户分配的缓冲区(与使用静态分配的缓冲区的 gethostbyname 相比)。
有人确切知道吗?
Is res_query (int res_query(const char *dname, int class, int type,unsigned char *answer,
) thread-safe?
int anslen);
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的, res_query 不是线程安全的。您必须使用 res_nquery,它首先接受“res_state”参数。从我读到的所有内容来看,这就是应该如何以线程安全的方式完成查询。
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.