Go to My Blog
Go to Lin's Blog

DNS解析

同步API,会阻塞:
getaddrinfo: IPV4 and IPV6, linux依赖<netdb.h>, windows依赖<ws2tcpip.h>
gethostbyname: only IPV4
异步:
libevent
getaddrinfo_a, 会执行注册的callback函数,

c-ares库,另起一线程,select/poll类似,监听socket并调用callback

   ares_gethostbyname 

在libcurl里,不会额外开线程,会在libcurl的线程里面不断的poll

调用ares,提交DNS请求:

(ares_gethostbyname)
(Curl_resolver_getaddrinfo+45)
(Curl_resolv+294)
(Curl_connect+6112)
(multi_runsingle+xx)
(curl_multi_perform+98)

Callback被调用

(query_completed_cb) curl/lib/asyn-ares.c:466
(end_hquery) cares/src/ares_gethostbyname.c:231
(qcallback) cares/src/ares_query.c:180
(end_query) cares/src/ares_process.c:1266
(process_answer) cares/src/ares_process.c:547
(processfds) cares/src/ares_process.c:152
(ares_process_fd+14) cares/src/ares_process.c:173
(waitperform +xx) curl/lib/asyn-ares.c:296
(Curl_resolver_is_resolved+22)
(multi_runsingle+xx)
(curl_multi_perform+98)

 

posted @ 2014-08-05 10:10  一ke小小草  阅读(961)  评论(0编辑  收藏  举报