CURLOPT_DNS_LOCAL_IP4.md (1650B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_DNS_LOCAL_IP4 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_DNS_INTERFACE (3) 9 - CURLOPT_DNS_LOCAL_IP6 (3) 10 - CURLOPT_DNS_SERVERS (3) 11 Protocol: 12 - All 13 Added-in: 7.33.0 14 --- 15 16 # NAME 17 18 CURLOPT_DNS_LOCAL_IP4 - IPv4 address to bind DNS resolves to 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_LOCAL_IP4, char *address); 26 ~~~ 27 28 # DESCRIPTION 29 30 Set the local IPv4 *address* that the resolver should bind to. The argument 31 should be of type char * and contain a single numerical IPv4 address as a 32 string. Set this option to NULL to use the default setting (do not bind to a 33 specific IP address). 34 35 The application does not have to keep the string around after setting this 36 option. 37 38 Using this option multiple times makes the last set string override the 39 previous ones. Set it to NULL to disable its use again. 40 41 # DEFAULT 42 43 NULL 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int main(void) 51 { 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 CURLcode res; 55 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 56 curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP4, "192.168.0.14"); 57 res = curl_easy_perform(curl); 58 curl_easy_cleanup(curl); 59 } 60 } 61 ~~~ 62 63 # NOTES 64 65 This option requires that libcurl was built with a resolver backend that 66 supports this operation. The c-ares backend is the only such one. 67 68 # %AVAILABILITY% 69 70 # RETURN VALUE 71 72 curl_easy_setopt(3) returns a CURLcode indicating success or error. 73 74 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 75 libcurl-errors(3).