Annotation of embedaddon/curl/docs/libcurl/curl_multi_poll.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: .TH curl_multi_poll 3 "November 17, 2019" "libcurl 7.70.0" "libcurl Manual"
                     23: 
                     24: .SH NAME
                     25: curl_multi_poll - polls on all easy handles in a multi handle
                     26: .SH SYNOPSIS
                     27: .nf
                     28: #include <curl/curl.h>
                     29: 
                     30: CURLMcode curl_multi_poll(CURLM *multi_handle,
                     31:                           struct curl_waitfd extra_fds[],
                     32:                           unsigned int extra_nfds,
                     33:                           int timeout_ms,
                     34:                           int *numfds);
                     35: .ad
                     36: .SH DESCRIPTION
                     37: \fIcurl_multi_poll(3)\fP polls all file descriptors used by the curl easy
                     38: handles contained in the given multi handle set.  It will block until activity
                     39: is detected on at least one of the handles or \fItimeout_ms\fP has passed.
                     40: Alternatively, if the multi handle has a pending internal timeout that has a
                     41: shorter expiry time than \fItimeout_ms\fP, that shorter time will be used
                     42: instead to make sure timeout accuracy is reasonably kept.
                     43: 
                     44: The calling application may pass additional curl_waitfd structures which are
                     45: similar to \fIpoll(2)\fP's pollfd structure to be waited on in the same call.
                     46: 
                     47: On completion, if \fInumfds\fP is non-NULL, it will be populated with the
                     48: total number of file descriptors on which interesting events occurred. This
                     49: number can include both libcurl internal descriptors as well as descriptors
                     50: provided in \fIextra_fds\fP.
                     51: 
                     52: The \fIcurl_multi_wakeup(3)\fP function can be used from another thread to
                     53: wake up this function and return faster. This is one of the details
                     54: that makes this function different than \fIcurl_multi_wait(3)\fP which cannot
                     55: be woken up this way.
                     56: 
                     57: If no extra file descriptors are provided and libcurl has no file descriptor
                     58: to offer to wait for, this function will instead wait during \fItimeout_ms\fP
                     59: milliseconds (or shorter if an internal timer indicates so). This is the
                     60: other detail that makes this function different than
                     61: \fIcurl_multi_wait(3)\fP.
                     62: 
                     63: This function is encouraged to be used instead of select(3) when using the
                     64: multi interface to allow applications to easier circumvent the common problem
                     65: with 1024 maximum file descriptors.
                     66: .SH curl_waitfd
                     67: .nf
                     68: struct curl_waitfd {
                     69:   curl_socket_t fd;
                     70:   short events;
                     71:   short revents;
                     72: };
                     73: .fi
                     74: .IP CURL_WAIT_POLLIN
                     75: Bit flag to curl_waitfd.events indicating the socket should poll on read
                     76: events such as new data received.
                     77: .IP CURL_WAIT_POLLPRI
                     78: Bit flag to curl_waitfd.events indicating the socket should poll on high
                     79: priority read events such as out of band data.
                     80: .IP CURL_WAIT_POLLOUT
                     81: Bit flag to curl_waitfd.events indicating the socket should poll on write
                     82: events such as the socket being clear to write without blocking.
                     83: .SH EXAMPLE
                     84: .nf
                     85: CURL *easy_handle;
                     86: CURLM *multi_handle;
                     87: 
                     88: /* add the individual easy handle */
                     89: curl_multi_add_handle(multi_handle, easy_handle);
                     90: 
                     91: do {
                     92:   CURLMcode mc;
                     93:   int numfds;
                     94: 
                     95:   mc = curl_multi_perform(multi_handle, &still_running);
                     96: 
                     97:   if(mc == CURLM_OK) {
                     98:     /* wait for activity or timeout */
                     99:     mc = curl_multi_poll(multi_handle, NULL, 0, 1000, &numfds);
                    100:   }
                    101: 
                    102:   if(mc != CURLM_OK) {
                    103:     fprintf(stderr, "curl_multi failed, code %d.\\n", mc);
                    104:     break;
                    105:   }
                    106: 
                    107: } while(still_running);
                    108: 
                    109: curl_multi_remove_handle(multi_handle, easy_handle);
                    110: .fi
                    111: .SH RETURN VALUE
                    112: CURLMcode type, general libcurl multi interface error code. See
                    113: \fIlibcurl-errors(3)\fP
                    114: .SH AVAILABILITY
                    115: This function was added in libcurl 7.66.0.
                    116: .SH "SEE ALSO"
                    117: .BR curl_multi_fdset "(3), " curl_multi_perform "(3), "
                    118: .BR curl_multi_wait "(3), " curl_multi_wakeup "(3)"

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