首页 > 代码库 > DNS解析

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

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

10:27:56.326 4382 4382 I AEE/AED : Backtrace:
10:27:56.326 4382 4382 I AEE/AED : #00 pc 00024014 /system/lib/libcurl.tgl.so (query_completed_cb) curl/lib/asyn-ares.c:466
10:27:56.326 4382 4382 I AEE/AED : #01 pc 000022bf /system/lib/libcares.so (end_hquery) cares/src/ares_gethostbyname.c:231
10:27:56.326 4382 4382 I AEE/AED : #02 pc 00006d81 /system/lib/libcares.so (qcallback) cares/src/ares_query.c:180
10:27:56.326 4382 4382 I AEE/AED : #03 pc 000065cb /system/lib/libcares.so (end_query) cares/src/ares_process.c:1266
10:27:56.326 4382 4382 I AEE/AED : #04 pc 000067d3 /system/lib/libcares.so (process_answer) cares/src/ares_process.c:547
10:27:56.326 4382 4382 I AEE/AED : #05 pc 00006a0b /system/lib/libcares.so (processfds) cares/src/ares_process.c:152
10:27:56.326 4382 4382 I AEE/AED : #06 pc 00006ceb /system/lib/libcares.so (ares_process_fd+14) cares/src/ares_process.c:173
10:27:56.326 4382 4382 I AEE/AED : #07 pc 00024113 /system/lib/libcurl.tgl.so (waitperform +xx) curl/lib/asyn-ares.c:296
10:27:56.326 4382 4382 I AEE/AED : #08 pc 0002422f /system/lib/libcurl.tgl.so (Curl_resolver_is_resolved+22)
10:27:56.326 4382 4382 I AEE/AED : #09 pc 0001ff59 /system/lib/libcurl.tgl.so (multi_runsingle+xx)
10:27:56.326 4382 4382 I AEE/AED : #10 pc 000206c3 /system/lib/libcurl.tgl.so (curl_multi_perform+98)