~ubuntu-branches/ubuntu/lucid/curl/lucid-security

« back to all changes in this revision

Viewing changes to docs/libcurl/curl_multi_socket.html

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-04-29 11:10:29 UTC
  • mfrom: (3.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090429111029-2j5eiyokfw2bw049
Tags: 7.19.4-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop build dependencies: stunnel, libdb4.6-dev, libssh2-1-dev
  - Add build-dependency on openssh-server
  - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.
  - Call automake-1.9 with --add-missing --copy --force
* drop debian/patches/security_CVE-2009-0037.patch 
  - this patch is part of 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 <p class="level0">CURLMcode curl_multi_socket_action(CURLM * multi_handle, 
51
51
 &nbsp;                                  curl_socket_t sockfd, int ev_bitmask,
52
52
 &nbsp;                                  int *running_handles);
53
 
 <p class="level0">CURLMcode curl_multi_socket(CURLM * multi_handle, curl_socket_t sockfd,
 
53
 </pre>
 
54
 
 
55
<p class="level0">
 
56
<p class="level0"><span Class="bold">Now deprecated versions:</span> <pre>
 
57
<p class="level0">CURLMcode curl_multi_socket(CURLM * multi_handle, curl_socket_t sockfd,
54
58
 &nbsp;                           int *running_handles);
55
59
 <p class="level0">CURLMcode curl_multi_socket_all(CURLM *multi_handle,
56
60
 &nbsp;                               int *running_handles);
57
61
 </pre>
58
62
 
59
63
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
60
 
<p class="level0">Alternative versions of <a class="emphasis" href="./curl_multi_perform.html">curl_multi_perform(3)</a> that allows the application to pass in the file descriptor/socket that has been detected to have "action" on it and let libcurl perform. This allows libcurl to not have to scan through all possible file descriptors to check for action. When the application has detected action on a socket handled by libcurl, it should call <span Class="emphasis">curl_multi_socket_action(3)</span> with the <span Class="bold">sockfd</span> argument set to the socket with the action. When the events on a socket are known, they can be passed as an events bitmask <span Class="bold">ev_bitmask</span> by first setting <span Class="bold">ev_bitmask</span> to 0, and then adding using bitwise OR (|) any combination of events to be chosen from CURL_CSELECT_IN, CURL_CSELECT_OUT or CURL_CSELECT_ERR. When the events on a socket are unknown, pass 0 instead, and libcurl will test the descriptor internally. 
61
 
<p class="level0">At return, the int <span Class="bold">running_handles</span> points to will contain the number of still running easy handles within the multi handle. When this number reaches zero, all transfers are complete/done. Note that when you call <span Class="emphasis">curl_multi_socket_action(3)</span> on a specific socket and the counter decreases by one, it DOES NOT necessarily mean that this exact socket/transfer is the one that completed. Use <a class="emphasis" href="./curl_multi_info_read.html">curl_multi_info_read(3)</a> to figure out which easy handle that completed. 
62
 
<p class="level0">The curl_multi_socket functions inform the application about updates in the socket (file descriptor) status by doing none, one or multiple calls to the socket callback function set with the CURLMOPT_SOCKETFUNCTION option to <a class="emphasis" href="./curl_multi_setopt.html">curl_multi_setopt(3)</a>. They update the status with changes since the previous time this function was called. 
63
 
<p class="level0">Force libcurl to (re-)check all its internal sockets and transfers instead of just a single one by calling <a class="bold" href="./curl_multi_socket_all.html">curl_multi_socket_all(3)</a>. Note that there should rarely be reasons to use this function! 
64
 
<p class="level0">Get the timeout time - how long to wait for socket actions at most before doing the timeout action: call the <a class="bold" href="./curl_multi_socket.html">curl_multi_socket(3)</a> function with the <span Class="bold">sockfd</span> argument set to CURL_SOCKET_TIMEOUT, by setting the <span Class="emphasis">CURLMOPT_TIMERFUNCTION</span> option with <a class="emphasis" href="./curl_multi_setopt.html">curl_multi_setopt(3)</a>. You can also use the <a class="emphasis" href="./curl_multi_timeout.html">curl_multi_timeout(3)</a> function to poll the value at any given time, but for an event-based system using the callback is far better than relying on polling the timeout value. 
65
 
<p class="level0">Usage of <a class="emphasis" href="./curl_multi_socket.html">curl_multi_socket(3)</a> is deprecated, whereas the function is equivalent to <span Class="emphasis">curl_multi_socket_action(3)</span>, when <span Class="bold">ev_bitmask</span> is set  to 0. 
66
 
<p class="level0"><a name="CALLBACK"></a><h2 class="nroffsh">CALLBACK DETAILS</h2>
 
64
<p class="level0">Alternative versions of <a class="emphasis" href="./curl_multi_perform.html">curl_multi_perform(3)</a> that allows the application to pass in the file descriptor/socket that has been detected to have "action" on it and let libcurl perform. This lets libcurl avoid having to scan through all possible file descriptors to check for action. 
 
65
<p class="level0">When the application has detected action on a socket handled by libcurl, it should call <span Class="emphasis">curl_multi_socket_action(3)</span> with the <span Class="bold">sockfd</span> argument set to the socket with the action. When the events on a socket are known, they can be passed as an events bitmask <span Class="bold">ev_bitmask</span> by first setting <span Class="bold">ev_bitmask</span> to 0, and then adding using bitwise OR (|) any combination of events to be chosen from CURL_CSELECT_IN, CURL_CSELECT_OUT or CURL_CSELECT_ERR. When the events on a socket are unknown, pass 0 instead, and libcurl will test the descriptor internally. 
 
66
<p class="level0">At return, the integer <span Class="bold">running_handles</span> points to will contain the number of still running easy handles within the multi handle. When this number reaches zero, all transfers are complete/done. Note that when you call <span Class="emphasis">curl_multi_socket_action(3)</span> on a specific socket and the counter decreases by one, it DOES NOT necessarily mean that this exact socket/transfer is the one that completed. Use <a class="emphasis" href="./curl_multi_info_read.html">curl_multi_info_read(3)</a> to figure out which easy handle that completed. 
 
67
<p class="level0">The <span Class="bold">curl_multi_socket_action(3)</span> functions inform the application about updates in the socket (file descriptor) status by doing none, one, or multiple calls to the socket callback function set with the CURLMOPT_SOCKETFUNCTION option to <a class="emphasis" href="./curl_multi_setopt.html">curl_multi_setopt(3)</a>. They update the status with changes since the previous time the callback was called. 
 
68
<p class="level0">Get the timeout time by setting the <span Class="emphasis">CURLMOPT_TIMERFUNCTION</span> option with <a class="emphasis" href="./curl_multi_setopt.html">curl_multi_setopt(3)</a>. Your application will then get called with information on how long to wait for socket actions at most before doing the timeout action: call the <span Class="bold">curl_multi_socket_action(3)</span> function with the <span Class="bold">sockfd</span> argument set to CURL_SOCKET_TIMEOUT. You can also use the <a class="emphasis" href="./curl_multi_timeout.html">curl_multi_timeout(3)</a> function to poll the value at any given time, but for an event-based system using the callback is far better than relying on polling the timeout value. 
 
69
<p class="level0">Usage of <a class="emphasis" href="./curl_multi_socket.html">curl_multi_socket(3)</a> is deprecated, whereas the function is equivalent to <span Class="emphasis">curl_multi_socket_action(3)</span> with <span Class="bold">ev_bitmask</span> set to 0. 
 
70
<p class="level0">Force libcurl to (re-)check all its internal sockets and transfers instead of just a single one by calling <a class="bold" href="./curl_multi_socket_all.html">curl_multi_socket_all(3)</a>. Note that there should not be any reason to use this function! <a name="CALLBACK"></a><h2 class="nroffsh">CALLBACK DETAILS</h2>
67
71
<p class="level0">
68
72
<p class="level0">The socket <span Class="bold">callback</span> function uses a prototype like this <pre>
69
73
<p class="level0"><p class="level0">&nbsp; int curl_socket_callback(CURL *easy,      /* easy handle */
92
96
<p class="level0">The <span Class="emphasis">socketp</span> argument is a private pointer you have previously set with <a class="emphasis" href="./curl_multi_assign.html">curl_multi_assign(3)</a> to be associated with the <span Class="emphasis">s</span> socket. If no pointer has been set, socketp will be NULL. This argument is of course a service to applications that want to keep certain data or structs that are strictly associated to the given socket. 
93
97
<p class="level0">The <span Class="emphasis">userp</span> argument is a private pointer you have previously set with <a class="emphasis" href="./curl_multi_setopt.html">curl_multi_setopt(3)</a> and the CURLMOPT_SOCKETDATA option. <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
94
98
<p class="level0">CURLMcode type, general libcurl multi interface error code. 
95
 
<p class="level0">If you receive <span Class="emphasis">CURLM_CALL_MULTI_PERFORM</span>, this basically means that you should call <a class="emphasis" href="./curl_multi_socket.html">curl_multi_socket(3)</a> again, before you wait for more actions on libcurl's sockets. You don't have to do it immediately, but the return code means that libcurl may have more data available to return or that there may be more data to send off before it is "satisfied". 
96
 
<p class="level0">NOTE that this only returns errors etc regarding the whole multi stack. There might still have occurred problems on individual transfers even when this function returns OK. <a name="TYPICAL"></a><h2 class="nroffsh">TYPICAL USAGE</h2>
 
99
<p class="level0">Legacy: If you receive <span Class="emphasis">CURLM_CALL_MULTI_PERFORM</span>, this basically means that you should call <a class="emphasis" href="./curl_multi_socket.html">curl_multi_socket(3)</a> again, before you wait for more actions on libcurl's sockets. You don't have to do it immediately, but the return code means that libcurl may have more data available to return or that there may be more data to send off before it is "satisfied". 
 
100
<p class="level0">In modern libcurls, <span Class="emphasis">CURLM_CALL_MULTI_PERFORM</span> or <span Class="emphasis">CURLM_CALL_MULTI_SOKCET</span> should not be returned and no application needs to care about them. 
 
101
<p class="level0">NOTE that the return code is for the whole multi stack. Problems still might have occurred on individual transfers even when one of these functions return OK. <a name="TYPICAL"></a><h2 class="nroffsh">TYPICAL USAGE</h2>
97
102
<p class="level0">1. Create a multi handle 
98
103
<p class="level0">2. Set the socket callback with CURLMOPT_SOCKETFUNCTION 
99
104
<p class="level0">3. Set the timeout callback with CURLMOPT_TIMERFUNCTION, to get to know what timeout value to use when waiting for socket activities. 
102
107
<p class="level0">6. Wait for activity on any of libcurl's sockets, use the timeout value your callback has been told 
103
108
<p class="level0">7, When activity is detected, call curl_multi_socket_action() for the socket(s) that got action. If no activity is detected and the timeout expires, call <span Class="emphasis">curl_multi_socket_action(3)</span> with <span Class="emphasis">CURL_SOCKET_TIMEOUT</span> 
104
109
<p class="level0">8. Go back to step 6. <a name="AVAILABILITY"></a><h2 class="nroffsh">AVAILABILITY</h2>
105
 
<p class="level0">This function was added in libcurl 7.15.4, although deemed stable since 7.16.0. 
 
110
<p class="level0">This function was added in libcurl 7.15.4, and is deemed stable since 7.16.0. 
106
111
<p class="level0"><a class="emphasis" href="./curl_multi_socket.html">curl_multi_socket(3)</a> is deprecated, use <span Class="emphasis">curl_multi_socket_action(3)</span> instead! <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
107
112
<p class="level0"><a class="manpage" href="./curl_multi_cleanup.html">curl_multi_cleanup (3)</a> <a class="manpage" href="./curl_multi_init.html">  curl_multi_init (3)</a> <span Class="manpage"> </span> <a class="manpage" href="./curl_multi_fdset.html">curl_multi_fdset (3)</a> <a class="manpage" href="./curl_multi_info_read.html">  curl_multi_info_read (3)</a> <span Class="manpage"> </span> <span Class="manpage">the hiperfifo.c example</span> <p class="roffit">
108
113
 This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.