DNS解析

同步API,会阻塞:
getaddrinfo: IPV4 and IPV6, linux依赖, windows依赖
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)

 

转载于:https://www.cnblogs.com/zzSoftware/p/3891630.html

你可能感兴趣的:(DNS解析)