1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_RESOLVER_START_FUNCTION 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_PREREQFUNCTION (3) 9 - CURLOPT_RESOLVER_START_DATA (3) 10Protocol: 11 - All 12--- 13 14# NAME 15 16CURLOPT_RESOLVER_START_FUNCTION - callback called before a new name resolve is started 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23int resolver_start_cb(void *resolver_state, void *reserved, void *userdata); 24 25CURLcode curl_easy_setopt(CURL *handle, 26 CURLOPT_RESOLVER_START_FUNCTION, 27 resolver_start_cb); 28~~~ 29 30# DESCRIPTION 31 32Pass a pointer to your callback function, which should match the prototype 33shown above. 34 35This callback function gets called by libcurl every time before a new resolve 36request is started. 37 38*resolver_state* points to a backend-specific resolver state. Currently only 39the ares resolver backend has a resolver state. It can be used to set up any 40desired option on the ares channel before it is used, for example setting up 41socket callback options. 42 43*reserved* is reserved. 44 45*userdata* is the user pointer set with the 46CURLOPT_RESOLVER_START_DATA(3) option. 47 48The callback must return 0 on success. Returning a non-zero value causes the 49resolve to fail. 50 51# DEFAULT 52 53NULL (No callback) 54 55# EXAMPLE 56 57~~~c 58static int start_cb(void *resolver_state, void *reserved, 59 void *userdata) 60{ 61 (void)reserved; 62 printf("Received resolver_state=%p userdata=%p\n", 63 resolver_state, userdata); 64 return 0; 65} 66 67int main(void) 68{ 69 CURL *curl = curl_easy_init(); 70 if(curl) { 71 curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, start_cb); 72 curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl); 73 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 74 curl_easy_perform(curl); 75 curl_easy_cleanup(curl); 76 } 77} 78~~~ 79 80# AVAILABILITY 81 82Added in 7.59.0 83 84# RETURN VALUE 85 86Returns CURLE_OK 87