xref: /curl/docs/libcurl/opts/CURLOPT_IPRESOLVE.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_IPRESOLVE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_HTTP_VERSION (3)
9  - CURLOPT_RESOLVE (3)
10  - CURLOPT_SSLVERSION (3)
11Protocol:
12  - All
13Added-in: 7.10.8
14---
15
16# NAME
17
18CURLOPT_IPRESOLVE - IP protocol version to use
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IPRESOLVE, long resolve);
26~~~
27
28# DESCRIPTION
29
30Allows an application to select what kind of IP addresses to use when
31establishing a connection or choosing one from the connection pool. This is
32interesting when using hostnames that resolve to more than one IP family.
33
34If the URL provided for a transfer contains a numerical IP version as a host
35name, this option does not override or prohibit libcurl from using that IP
36version.
37
38Available values for this option are:
39
40## CURL_IPRESOLVE_WHATEVER
41
42Default, can use addresses of all IP versions that your system allows.
43
44## CURL_IPRESOLVE_V4
45
46Uses only IPv4 addresses.
47
48## CURL_IPRESOLVE_V6
49
50Uses only IPv6 addresses.
51
52# DEFAULT
53
54CURL_IPRESOLVE_WHATEVER
55
56# %PROTOCOLS%
57
58# EXAMPLE
59
60~~~c
61int 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
82Returns CURLE_OK
83