1 .\" **************************************************************************
3 .\" * Project ___| | | | _ \| |
4 .\" * / __| | | | |_) | |
5 .\" * | (__| |_| | _ <| |___
6 .\" * \___|\___/|_| \_\_____|
8 .\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at https://curl.haxx.se/docs/copyright.html.
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
21 .\" **************************************************************************
23 .TH CURLMOPT_TIMERDATA 3 "May 27, 2017" "libcurl 7.59.0" "curl_multi_setopt options"
26 CURLMOPT_TIMERDATA \- custom pointer to pass to timer callback
29 #include <curl/curl.h>
31 CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer);
33 A data \fBpointer\fP to pass to the timer callback set with the
34 \fICURLMOPT_TIMERFUNCTION(3)\fP option.
36 This pointer will not be touched by libcurl but will only be passed in to the
37 timer callbacks's \fBuserp\fP argument.
44 static gboolean timeout_cb(gpointer user_data)
49 curl_multi_setopt(curl_handle, CURLMOPT_TIMERDATA, NULL);
51 curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running);
52 return G_SOURCE_REMOVE;
55 static int timerfunc(CURLM *multi, long timeout_ms, void *userp)
62 /* -1 means we should just delete our timer. */
63 if(timeout_ms == -1) {
70 *id = g_timeout_add(timeout_ms, timeout_cb, id);
72 curl_multi_setopt(multi, CURLMOPT_TIMERDATA, id);
76 curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
81 Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
83 .BR CURLMOPT_TIMERFUNCTION "(3), " CURLMOPT_SOCKETFUNCTION "(3), "