CURLOPT_IPRESOLVE.md (1724B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_IPRESOLVE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_HTTP_VERSION (3) 9 - CURLOPT_RESOLVE (3) 10 - CURLOPT_SSLVERSION (3) 11 Protocol: 12 - All 13 Added-in: 7.10.8 14 --- 15 16 # NAME 17 18 CURLOPT_IPRESOLVE - IP protocol version to use 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IPRESOLVE, long resolve); 26 ~~~ 27 28 # DESCRIPTION 29 30 Allows an application to select what kind of IP addresses to use when 31 establishing a connection or choosing one from the connection pool. This is 32 interesting when using hostnames that resolve to more than one IP family. 33 34 If the URL provided for a transfer contains a numerical IP version as a host 35 name, this option does not override or prohibit libcurl from using that IP 36 version. 37 38 Available values for this option are: 39 40 ## CURL_IPRESOLVE_WHATEVER 41 42 Default, can use addresses of all IP versions that your system allows. 43 44 ## CURL_IPRESOLVE_V4 45 46 Uses only IPv4 addresses. 47 48 ## CURL_IPRESOLVE_V6 49 50 Uses only IPv6 addresses. 51 52 # DEFAULT 53 54 CURL_IPRESOLVE_WHATEVER 55 56 # %PROTOCOLS% 57 58 # EXAMPLE 59 60 ~~~c 61 int main(void) 62 { 63 CURL *curl = curl_easy_init(); 64 if(curl) { 65 CURLcode res; 66 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 67 68 /* of all addresses example.com resolves to, only IPv6 ones are used */ 69 curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); 70 71 res = curl_easy_perform(curl); 72 73 curl_easy_cleanup(curl); 74 } 75 } 76 ~~~ 77 78 # %AVAILABILITY% 79 80 # RETURN VALUE 81 82 curl_easy_setopt(3) returns a CURLcode indicating success or error. 83 84 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 85 libcurl-errors(3).