1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLMOPT_TIMERDATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLMOPT_SOCKETFUNCTION (3)
9  - CURLMOPT_TIMERFUNCTION (3)
10---
11
12# NAME
13
14CURLMOPT_TIMERDATA - custom pointer to pass to timer callback
15
16# SYNOPSIS
17
18~~~c
19#include <curl/curl.h>
20
21CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer);
22~~~
23
24# DESCRIPTION
25
26A data **pointer** to pass to the timer callback set with the
27CURLMOPT_TIMERFUNCTION(3) option.
28
29This pointer is not touched by libcurl but is only be passed in to the timer
30callbacks's **clientp** argument.
31
32# DEFAULT
33
34NULL
35
36# PROTOCOLS
37
38All
39
40# EXAMPLE
41
42~~~c
43struct priv {
44  void *custom;
45};
46
47static int timerfunc(CURLM *multi, long timeout_ms, void *clientp)
48{
49 struct priv *mydata = clientp;
50 printf("our ptr: %p\n", mydata->custom);
51
52 if(timeout_ms) {
53   /* this is the new single timeout to wait for */
54 }
55 else {
56   /* delete the timeout, nothing to wait for now */
57 }
58}
59
60int main(void)
61{
62  struct priv mydata;
63  CURLM *multi = curl_multi_init();
64  curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
65  curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata);
66}
67~~~
68
69# AVAILABILITY
70
71Added in 7.16.0
72
73# RETURN VALUE
74
75Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
76