Imported Upstream version 7.50.2
[platform/upstream/curl.git] / docs / libcurl / opts / CURLMOPT_SOCKETFUNCTION.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
9 .\" *
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.
13 .\" *
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.
17 .\" *
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
20 .\" *
21 .\" **************************************************************************
22 .\"
23 .TH CURLMOPT_SOCKETFUNCTION 3 "3 Nov 2016" "libcurl 7.39.0" "curl_multi_setopt options"
24 .SH NAME
25 CURLMOPT_SOCKETFUNCTION \- callback informed about what to wait for
26 .SH SYNOPSIS
27 .nf
28 #include <curl/curl.h>
29
30 int socket_callback(CURL *easy,      /* easy handle */
31                     curl_socket_t s, /* socket */
32                     int what,        /* describes the socket */
33                     void *userp,     /* private callback pointer */
34                     void *socketp);  /* private socket pointer */
35
36 CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_SOCKETFUNCTION, socket_callback);
37 .SH DESCRIPTION
38 Pass a pointer to your callback function, which should match the prototype
39 shown above.
40
41 When the \fIcurl_multi_socket_action(3)\fP function runs, it informs the
42 application about updates in the socket (file descriptor) status by doing
43 none, one, or multiple calls to the \fBsocket_callback\fP. The callback gets
44 status updates with changes since the previous time the callback was called.
45 If the given callback pointer is NULL, no callback will be called. Set the
46 callback's \fBuserp\fP argument with \fICURLMOPT_SOCKETDATA(3)\fP.  See
47 \fIcurl_multi_socket_action(3)\fP for more details on how the callback is used
48 and should work.
49
50 The \fBwhat\fP parameter informs the callback on the status of the given
51 socket. It can hold one of these values:
52 .IP CURL_POLL_IN
53 Wait for incoming data. For the socket to become readable.
54 .IP CURL_POLL_OUT
55 Wait for outgoing data. For the socket to become writable.
56 .IP CURL_POLL_INOUT
57 Wait for incoming and outgoing data. For the socket to become readable or
58 writable.
59 .IP CURL_POLL_REMOVE
60 The specified socket/file descriptor is no longer used by libcurl.
61 .SH DEFAULT
62 NULL (no callback)
63 .SH PROTOCOLS
64 All
65 .SH EXAMPLE
66 TODO
67 .SH AVAILABILITY
68 Added in 7.15.4
69 .SH RETURN VALUE
70 Returns CURLM_OK.
71 .SH "SEE ALSO"
72 .BR CURLMOPT_SOCKETDATA "(3), " curl_multi_socket_action "(3), "
73 .BR CURLMOPT_TIMERFUNCTION "(3) "
74