Annotation of embedaddon/curl/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.3, revision 1.1.1.1

1.1       misho       1: .\" **************************************************************************
                      2: .\" *                                  _   _ ____  _
                      3: .\" *  Project                     ___| | | |  _ \| |
                      4: .\" *                             / __| | | | |_) | |
                      5: .\" *                            | (__| |_| |  _ <| |___
                      6: .\" *                             \___|\___/|_| \_\_____|
                      7: .\" *
                      8: .\" * Copyright (C) 1998 - 2019, 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 "June 24, 2019" "libcurl 7.70.0" "curl_multi_setopt options"
                     24: 
                     25: .SH NAME
                     26: CURLMOPT_SOCKETFUNCTION \- callback informed about what to wait for
                     27: .SH SYNOPSIS
                     28: .nf
                     29: #include <curl/curl.h>
                     30: 
                     31: int socket_callback(CURL *easy,      /* easy handle */
                     32:                     curl_socket_t s, /* socket */
                     33:                     int what,        /* describes the socket */
                     34:                     void *userp,     /* private callback pointer */
                     35:                     void *socketp);  /* private socket pointer */
                     36: 
                     37: CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_SOCKETFUNCTION, socket_callback);
                     38: .SH DESCRIPTION
                     39: Pass a pointer to your callback function, which should match the prototype
                     40: shown above.
                     41: 
                     42: When the \fIcurl_multi_socket_action(3)\fP function is called, it informs the
                     43: application about updates in the socket (file descriptor) status by doing
                     44: none, one, or multiple calls to the \fBsocket_callback\fP. The callback
                     45: function gets status updates with changes since the previous time the callback
                     46: was called. If the given callback pointer is set to NULL, no callback will be
                     47: called.
                     48: .SH "CALLBACK ARGUMENTS"
                     49: \fIeasy\fP identifies the specific transfer for which this update is related.
                     50: 
                     51: \fIs\fP is the specific socket this function invocation concerns. If the
                     52: \fBwhat\fP argument is not CURL_POLL_REMOVE then it holds information about
                     53: what activity on this socket the application is supposed to
                     54: monitor. Subsequent calls to this callback might update the \fBwhat\fP bits
                     55: for a socket that is already monitored.
                     56: 
                     57: \fBuserp\fP is set with \fICURLMOPT_SOCKETDATA(3)\fP.
                     58: 
                     59: \fBsocketp\fP is set with \fIcurl_multi_assign(3)\fP or will be NULL.
                     60: 
                     61: The \fBwhat\fP parameter informs the callback on the status of the given
                     62: socket. It can hold one of these values:
                     63: .IP CURL_POLL_IN
                     64: Wait for incoming data. For the socket to become readable.
                     65: .IP CURL_POLL_OUT
                     66: Wait for outgoing data. For the socket to become writable.
                     67: .IP CURL_POLL_INOUT
                     68: Wait for incoming and outgoing data. For the socket to become readable or
                     69: writable.
                     70: .IP CURL_POLL_REMOVE
                     71: The specified socket/file descriptor is no longer used by libcurl.
                     72: .SH DEFAULT
                     73: NULL (no callback)
                     74: .SH PROTOCOLS
                     75: All
                     76: .SH EXAMPLE
                     77: .nf
                     78: static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
                     79: {
                     80:   GlobalInfo *g = (GlobalInfo*) cbp;
                     81:   SockInfo *fdp = (SockInfo*) sockp;
                     82: 
                     83:   if(what == CURL_POLL_REMOVE) {
                     84:     remsock(fdp);
                     85:   }
                     86:   else {
                     87:     if(!fdp) {
                     88:       addsock(s, e, what, g);
                     89:     }
                     90:     else {
                     91:       setsock(fdp, s, e, what, g);
                     92:     }
                     93:   }
                     94:   return 0;
                     95: }
                     96: 
                     97: main()
                     98: {
                     99:   GlobalInfo setup;
                    100:   /* ... use socket callback and custom pointer */
                    101:   curl_multi_setopt(multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
                    102:   curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, &setup);
                    103: }
                    104: .fi
                    105: .SH AVAILABILITY
                    106: Added in 7.15.4
                    107: .SH RETURN VALUE
                    108: Returns CURLM_OK.
                    109: .SH "SEE ALSO"
                    110: .BR CURLMOPT_SOCKETDATA "(3), " curl_multi_socket_action "(3), "
                    111: .BR CURLMOPT_TIMERFUNCTION "(3) "

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>