On the resolution of DNS domain names in the process of wget and curl requests

for work reasons, I used the strace command to track the whole process of curl and wget requests, and the conclusion about DNS domain name resolution is as follows. Some of them do not understand, and the source code does not understand (operation and maintenance one), please give assistance, thank you!

assume that the total domain name is test.domain.com, and DNS is configured with 2 A records
Test commands:
strace curl-v test.domain.com
strace wget test.domain.com

my conclusion:
(1) curl is implemented through libcurl cross-platform database. I don"t understand how or how curl changes from domain name to IP address. However, curl is used to request many times. From the result of strace, it does not poll the IP address that requests two A records.

(2) compared with curl, a wget request spends a lot of time on domain name resolution. In the case of finding hosts files in vain, obtain all ip addresses by parsing in a dig-like way and select one of them to request data, and test many times. The result: it can poll and use DNS parsed (2 A record IP) to request resources.

my question:
I want to learn more about the principles of curl and wget (especially curl) about DNS domain name resolution


curl uses a child thread to do the DNS query, so you have to use strace-f to see it.

take a look at the code of curl. There are many implementations of DNS parsing. The version I use is asynchronous DNS, implemented by threads, but all the Curl_getaddrinfo_ex functions that perform parsing are curl_addrinfo.c , in which getaddrinfo is called to get the IP list.

Menu