3

res_query ( int res_query(const char *dname, int class, int type,unsigned char *answer, int anslen);) 是线程安全的吗?

我认为是这样,因为它将答案写入用户分配的缓冲区(与使用静态分配的缓冲区的 gethostbyname 形成对比)。

有人确定吗?

4

1 回答 1

2

你是对的, res_query 不是线程安全的。您必须使用 res_nquery,它首先采用“res_state”参数。从我读过的所有内容来看,这就是应该以线程安全的方式完成查询的方式。

于 2011-02-13T02:06:09.627 回答