cURL / Mailing Lists / curl-library / Single Mail

curl-library

when domain lookup result has ipv6 and ipv4

From: Vincent Chen <silence.vincent_at_gmail.com>
Date: Thu, 2 Jul 2015 09:59:05 +0800

Hi everyone,

I'm developing a HTTP client with multi interface and have some questions
when domain name look up has both IPv6 & IPv4 address

[Question1]
I implement the opensocket call back to create socket by myself and monitor
socket event.

and found the callback will be called twice.

First callback is for IPv6 and the second callback is for IPv4.

here is the logs I print to understand calling order:

----------------------------------------------------------------------------------------------------------------------------------------
[opensocket_cb] purpose: 0, family: 10, is_socket_open 0

[opensocket_cb] open socket ok, socket num: 32

[curl_debug] Trying 2600:1417:1b::cb45:8d19...

[sock_cb] easy=0x332f760 socket=32 what=OUT

[opensocket_cb] purpose: 0, family: 2, is_socket_open 1

[curl_debug] Connected to tmsps300-en.census.trendmicro.com
(2600:1417:1b::cb45:8d19) port 80 (#0)
----------------------------------------------------------------------------------------------------------------------------------------

If the curl decides to connect with IPv6 address in line #2, why it calls
opensocket callback with IPv4 again?

[Question 2]
Is it possible to change opensocket callback order?
for example, call "opensocket callback" for IPv4 first, then IPv6.

[Question 3]
Is it possible to try both IPv6 & IPv4 connectivity?
for example, trying IPv6 connection, if it failed, keep trying IPv4
connection.
What I found is libcurl will try IPv6 only and not try IPv4 address...

Because some domain name can establish connection via IPv6 address and some
cannot.
Although libcurl provides a option CURLOPT_IPRESOLVE can setup resolve
preference.
I still can not disable IPv6 resolving to be the workaround for some
reasons :-]

Thanks for help!!
Vincent

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-07-02