cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: If a given url has serveral host IP addresses, which one curl will take?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 28 Sep 2015 10:23:55 +0200 (CEST)

On Mon, 28 Sep 2015, Wang Meng wrote:

> If I curl a url just like this:curl http://curl.haxx.se/

> My question is when curl get one more host IP addresses from
> gethostbyname_r, which one it will take to connect?
> I thought curl will traversal addresses in h_addr_list from the first to
> the end, if it got a usable host IP address, it will break and do the
> transfer work, if transfer work done on this usable address, curl will give
> the result and exit.

It will iterate over them all the first one that works, it will use.

If you get both A and AAAA addresses back and your host is IPv6 capable, it
will try to connect to both IPv4 and IPv6 addresses in parallel. The first one
to connect wins, the other one is closed and forgotten.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-09-28