1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_ADDRESS_SCOPE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_DEBUGFUNCTION (3)
9  - CURLOPT_STDERR (3)
10---
11
12# NAME
13
14CURLOPT_ADDRESS_SCOPE - scope id for IPv6 addresses
15
16# SYNOPSIS
17
18~~~c
19#include <curl/curl.h>
20
21CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ADDRESS_SCOPE, long scope);
22~~~
23
24# DESCRIPTION
25
26Pass a long specifying the scope id value to use when connecting to IPv6 addresses.
27
28# DEFAULT
29
300
31
32# PROTOCOLS
33
34All, when using IPv6
35
36# EXAMPLE
37
38~~~c
39#include <net/if.h> /* for if_nametoindex() */
40
41int main(void)
42{
43  CURL *curl = curl_easy_init();
44  if(curl) {
45    CURLcode ret;
46    long my_scope_id;
47    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
48    my_scope_id = if_nametoindex("eth0");
49    curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id);
50    ret = curl_easy_perform(curl);
51    curl_easy_cleanup(curl);
52  }
53}
54~~~
55
56# AVAILABILITY
57
58Added in 7.19.0
59
60# RETURN VALUE
61
62Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
63Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value.
64