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