1CURLOPT_RESOLVER_START_FUNCTcIuOrNl(_3e)asy_setopt oCpUtRiLoOnPsT_RESOLVER_START_FUNCTION(3)
2
3
4

NAME

6       CURLOPT_RESOLVER_START_FUNCTION - callback called before a new name re‐
7       solve is started
8

SYNOPSIS

10       #include <curl/curl.h>
11
12       int resolver_start_cb(void *resolver_state, void *reserved, void *userdata);
13
14       CURLcode curl_easy_setopt(CURL *handle,
15                                 CURLOPT_RESOLVER_START_FUNCTION,
16                                 resolver_start_cb);
17

DESCRIPTION

19       Pass a pointer to your callback function, which should match the proto‐
20       type shown above.
21
22       This  callback  function gets called by libcurl every time before a new
23       resolve request is started.
24
25       resolver_state points to a backend-specific resolver  state.  Currently
26       only  the ares resolver backend has a resolver state. It can be used to
27       set up any desired option on the ares channel before it's used, for ex‐
28       ample setting up socket callback options.
29
30       reserved is reserved.
31
32       userdata    is    the   user   pointer   set   with   the   CURLOPT_RE‐
33       SOLVER_START_DATA(3) option.
34
35       The callback must return 0 on success. Returning a non-zero value  will
36       cause the resolve to fail.
37

DEFAULT

39       NULL (No callback)
40

PROTOCOLS

42       All
43

EXAMPLE

45       static int resolver_start_cb(void *resolver_state, void *reserved,
46                                    void *userdata)
47       {
48         (void)reserved;
49         printf("Received resolver_state=%p userdata=%p\n",
50                resolver_state, userdata);
51         return 0;
52       }
53
54       CURL *curl = curl_easy_init();
55       if(curl) {
56         curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_start_cb);
57         curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
58         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
59         curl_easy_perform(curl);
60         curl_easy_cleanup(curl);
61       }
62

AVAILABILITY

64       Added in 7.59.0
65

RETURN VALUE

67       Returns CURLE_OK
68

SEE ALSO

70       CURLOPT_RESOLVER_START_DATA(3)
71
72
73
74libcurl 7.85.0                   May 17, 2022CURLOPT_RESOLVER_START_FUNCTION(3)
Impressum