当前位置: 技术问答>linux和unix
有没有人用过异步DNS解析库adns的?
来源: 互联网 发布时间:2015-11-10
本文导语: http://www.chiark.greenend.org.uk/~ian/adns/ 上面是他的官方文档,我写了一个测试程序,源码如下: #include #include #include "adns.h" int main(int argc, char *argv[]) { adns_state adns; adns_query query; adns_answer *answer; ...
http://www.chiark.greenend.org.uk/~ian/adns/
上面是他的官方文档,我写了一个测试程序,源码如下:
#include
#include
#include "adns.h"
int main(int argc, char *argv[]) {
adns_state adns;
adns_query query;
adns_answer *answer;
adns_init(&adns, adns_if_noenv, 0); /////////////////////////////////
adns_submit(adns, argv[1], adns_r_ptr,
adns_qf_quoteok_cname|adns_qf_cname_loose,
NULL, &query);
adns_wait(adns, &query, &answer, NULL);
printf("%sn", answer->status == adns_s_ok ? *answer->rrs.str : "dunno");
adns_finish(adns);
return 0;
}
结果就是"dunno",如果把adns_init的adns_if_noenv改成adns_if_debug,则出现以下错误:
adns debug: environment variable RES_OPTIONS not set
adns debug: environment variable ADNS_RES_OPTIONS not set
adns debug: using nameserver 192.168.20.1
adns debug: environment variable RES_CONF not set
adns debug: environment variable ADNS_RES_CONF not set
adns debug: environment variable RES_CONF_TEXT not set
adns debug: environment variable ADNS_RES_CONF_TEXT not set
adns debug: environment variable LOCALDOMAIN not set
adns debug: environment variable ADNS_LOCALDOMAIN not set
弄了好几天了,都没弄明白怎么回事,盼求解惑,bow~
--
上面是他的官方文档,我写了一个测试程序,源码如下:
#include
#include
#include "adns.h"
int main(int argc, char *argv[]) {
adns_state adns;
adns_query query;
adns_answer *answer;
adns_init(&adns, adns_if_noenv, 0); /////////////////////////////////
adns_submit(adns, argv[1], adns_r_ptr,
adns_qf_quoteok_cname|adns_qf_cname_loose,
NULL, &query);
adns_wait(adns, &query, &answer, NULL);
printf("%sn", answer->status == adns_s_ok ? *answer->rrs.str : "dunno");
adns_finish(adns);
return 0;
}
结果就是"dunno",如果把adns_init的adns_if_noenv改成adns_if_debug,则出现以下错误:
adns debug: environment variable RES_OPTIONS not set
adns debug: environment variable ADNS_RES_OPTIONS not set
adns debug: using nameserver 192.168.20.1
adns debug: environment variable RES_CONF not set
adns debug: environment variable ADNS_RES_CONF not set
adns debug: environment variable RES_CONF_TEXT not set
adns debug: environment variable ADNS_RES_CONF_TEXT not set
adns debug: environment variable LOCALDOMAIN not set
adns debug: environment variable ADNS_LOCALDOMAIN not set
弄了好几天了,都没弄明白怎么回事,盼求解惑,bow~
--
|
参数adns_r_ptr改为adns_r_a
#include
#include
#include "adns.h"
int main(int argc, char *argv[]) {
adns_state adns;
adns_query query;
adns_answer *answer;
adns_init(&adns, adns_if_noenv, 0);
adns_submit(adns, argv[1], adns_r_a,//Use this parameter
adns_qf_quoteok_cname|adns_qf_cname_loose,
NULL, &query);
adns_wait(adns, &query, &answer, NULL);
adns_check(adns, &query, &answer, NULL);
printf("%sn", answer->status == adns_s_ok ? inet_ntoa(*answer->rrs.inaddr) : "dunno");
adns_finish(adns);
return 0;
}
#include
#include
#include "adns.h"
int main(int argc, char *argv[]) {
adns_state adns;
adns_query query;
adns_answer *answer;
adns_init(&adns, adns_if_noenv, 0);
adns_submit(adns, argv[1], adns_r_a,//Use this parameter
adns_qf_quoteok_cname|adns_qf_cname_loose,
NULL, &query);
adns_wait(adns, &query, &answer, NULL);
adns_check(adns, &query, &answer, NULL);
printf("%sn", answer->status == adns_s_ok ? inet_ntoa(*answer->rrs.inaddr) : "dunno");
adns_finish(adns);
return 0;
}
|
mark