[From My Stackoverflow question
<https://stackoverflow.com/questions/48359210/using-curlopt-connect-to-with-an-ipv6-address/48363610?noredirect=1#comment83739287_48363610>
]

I am attempting to use curl's CURLOPT_CONNECT_TO option to connect to a
specific address (rather than the result of the DNS lookup of the host part
of the url):

CURL * r_curl = NULL;
struct curl_slist * r_connect = NULL;
char connectStr[128];

if (af == AF_INET) {
    sprintf(connectStr, "::%s:", ipAddrString);
} else if (af == AF_INET6) {
    /* in [] per https://curl.haxx.se/libcurl/c/CURLOPT_CONNECT_TO.html */
    sprintf(connectStr, "::[%s]:", ipAddrString);
}
fprintf(stderr, "DEBUG: connect '%s', url %s\n", connectStr, url);

r_curl = curl_easy_init();
    ...
r_connect = curl_slist_append(r_connect, connectStr);
curl_easy_setopt(r_curl, CURLOPT_CONNECT_TO, r_connect);
curl_easy_setopt(r_curl, CURLOPT_URL, url);
curl_easy_perform(r_curl);


​Result:

DEBUG: connect '::[2610:130:101:104::2]:', url http://www.iastate.edu/
* Connecting to hostname: 2610:130:101:104::2
* Could not resolve host: 2610:130:101:104::2


​I would like to suggest that returning some sort of error like
CURLE_NO_IPV6_SUPPORT (or at least
CURLE_NOT_BUILT_IN
​) ​
would be more helpful.

However, it is not clear to me whether this should happen on the
curl_easy_setopt
​(​
CURLOPT_CONNECT_TO
​) call or on the ​
curl_easy_perform
​() call.

​
This was with version 7.56.1

John
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Reply via email to