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