cURL / Mailing Lists / curl-library / Single Mail


Re: multihomed connections

From: Gisle Vanem <>
Date: Tue, 8 Jun 2004 20:18:40 +0200

"Daniel Stenberg" <> said:

> > How is curl/libcurl supposed to connect to a host with multiple IPv4
> > addresses? I image it would try each address in succession.
> Yes, it should definitely. Anything else is a bug!

The fix to 'curl url1 url2' where url1 fails, is easy:

--- CVS-latest/src/main.c Tue May 25 16:44:25 2004
+++ src/main.c Tue Jun 08 19:37:18 2004
@@ -2904,7 +2904,7 @@

   /* loop through the list of given URLs */
- while(urlnode && !res) {
+ while(urlnode) {
     char *dourl;

     /* get the full URL (it might be NULL) */

The other "bug" in libcurl is not a bug at all, but rather inconsitent
behaviour depending on which resolver is used.
>curl -v4
* Couldn't find host in the .netrc file, using defaults
416: not yet
139: dump_addrinfo:
    fam  2, CNAME <none>,
    fam  2, CNAME <none>,
    fam  2, CNAME <none>,
    fam  2, CNAME <none>,
    fam  2, CNAME <none>,
    fam  2, CNAME <none>,
    fam  2, CNAME <none>,
353: getaddrinfo_thread() status 0, thread retval 0, 361: elapsed 15 ms
* About to connect() to port 80
* Connect failed; Connection refused
* Closing connection #0
curl: (7) Connect failed; Connection refused
Okay, the "refused" came from the last IP. Using tcpdump, I see curl
tries the addresses in the above order. But with a C-ares version, the
result is "timed out". Since the last IP it tried was
It would be nice if libcurl could tell us all the IP it tried and the result of
each failed attempt.
I.e. C-ares returns a completely different IP-order compared to what getaddrinfo() 
says. It looks like the DNS for this host is misconfigured too. Isn't addresses 
supposed to be listed in *prefered* order? 
BTW. try "adig" and watch the IP-order changes constantly.
Whereas the dig or host programs gives a more stable list of IPs.
Received on 2004-06-08