cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_RESOLVE and cycling through addresses (avoiding lack-of-IPv6-connectivity)

From: Andreux Fort <andrew.fort_at_gmail.com>
Date: Fri, 11 Oct 2013 09:00:58 -0700

Hi folks,

I'm deploying libcurl for an application where:

* Hosts may or may not have IPv6 connectivity
* In our system framework, we're getting DNS resolution records from an
external resolver. I take the A/AAAA records and place them in a
datastructure.

Then, we create an easy handle, create *curl_slist for our CURLOPT_RESOLVE
entries, and then add the IPv6 entries first, followed by the IPv4
addresses.

So, if we get an IPv6 address, we'll attempt to connect, and if we don't
have any IPv6 connectivity, we get CURLcode 7. Okay, cool, but... my next
request (new easy handle) does the same thing and makes the same
connection, and so we end up with a failure to connect to the v4 addresses.

My question is - after reading url.c/hostip.c and not entirely following
the scoping - how do I get libcurl to cycle through the addresses given to
it? I am NOT reusing easy handles, I imagine this is the issue. If I
reuse an easy handle, will libcurl cycle through addresses for me? Or is
it preferable to feed just one address into the CURLOPT_RESOLVE option and
deal with that externally in my application? Other than keeping track of
my easy handle for a request and calling curl_easy_reset() after each
request, is there anything else I need to do?

(*) Is the correct way to get the errno from curl_multi_socket_action to
register my socket for EPOLLERR and then use getsockopt with SO_ERROR?

Thanks again for libcurl!

Andrew

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-10-11