1curl_multi_poll(3)              libcurl Manual              curl_multi_poll(3)
2
3
4

NAME

6       curl_multi_poll - polls on all easy handles in a multi handle
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLMcode curl_multi_poll(CURLM *multi_handle,
12                                 struct curl_waitfd extra_fds[],
13                                 unsigned int extra_nfds,
14                                 int timeout_ms,
15                                 int *numfds);
16

DESCRIPTION

18       curl_multi_poll(3)  polls  all  file  descriptors used by the curl easy
19       handles contained in the given multi handle set.  It will  block  until
20       activity  is  detected on at least one of the handles or timeout_ms has
21       passed.  Alternatively, if the multi  handle  has  a  pending  internal
22       timeout  that  has  a shorter expiry time than timeout_ms, that shorter
23       time will be used instead to make sure timeout accuracy  is  reasonably
24       kept.
25
26       The  calling  application  may  pass  additional curl_waitfd structures
27       which are similar to poll(2)'s pollfd structure to be waited on in  the
28       same call.
29
30       On  completion,  if  numfds  is non-NULL, it will be populated with the
31       total number of file descriptors on which interesting events  occurred.
32       This  number  can  include both libcurl internal descriptors as well as
33       descriptors provided in extra_fds.
34
35       The curl_multi_wakeup(3) function can be used from  another  thread  to
36       wake  up  this  function  and return faster. This is one of the details
37       that makes this function different than curl_multi_wait(3) which cannot
38       be woken up this way.
39
40       If  no  extra  file  descriptors  are  provided and libcurl has no file
41       descriptor to offer to wait for, this function will instead wait during
42       timeout_ms milliseconds (or shorter if an internal timer indicates so).
43       This is the other  detail  that  makes  this  function  different  than
44       curl_multi_wait(3).
45
46       This  function is encouraged to be used instead of select(3) when using
47       the multi interface to allow applications to easier circumvent the com‐
48       mon problem with 1024 maximum file descriptors.
49

curl_waitfd

51       struct curl_waitfd {
52         curl_socket_t fd;
53         short events;
54         short revents;
55       };
56
57       CURL_WAIT_POLLIN
58              Bit flag to curl_waitfd.events indicating the socket should poll
59              on read events such as new data received.
60
61       CURL_WAIT_POLLPRI
62              Bit flag to curl_waitfd.events indicating the socket should poll
63              on high priority read events such as out of band data.
64
65       CURL_WAIT_POLLOUT
66              Bit flag to curl_waitfd.events indicating the socket should poll
67              on write events such as the socket being clear to write  without
68              blocking.
69

EXAMPLE

71       CURL *easy_handle;
72       CURLM *multi_handle;
73
74       /* add the individual easy handle */
75       curl_multi_add_handle(multi_handle, easy_handle);
76
77       do {
78         CURLMcode mc;
79         int numfds;
80
81         mc = curl_multi_perform(multi_handle, &still_running);
82
83         if(mc == CURLM_OK) {
84           /* wait for activity or timeout */
85           mc = curl_multi_poll(multi_handle, NULL, 0, 1000, &numfds);
86         }
87
88         if(mc != CURLM_OK) {
89           fprintf(stderr, "curl_multi failed, code %d.\n", mc);
90           break;
91         }
92
93       } while(still_running);
94
95       curl_multi_remove_handle(multi_handle, easy_handle);
96

RETURN VALUE

98       CURLMcode  type,  general  libcurl  multi  interface  error  code.  See
99       libcurl-errors(3)
100

AVAILABILITY

102       This function was added in libcurl 7.66.0.
103

SEE ALSO

105       curl_multi_fdset(3),     curl_multi_perform(3),     curl_multi_wait(3),
106       curl_multi_wakeup(3)
107
108
109
110libcurl 7.69.1                 November 17, 2019            curl_multi_poll(3)
Impressum