~ubuntu-branches/ubuntu/intrepid/curl/intrepid-security

« back to all changes in this revision

Viewing changes to docs/libcurl/curl_multi_socket.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:56:48 UTC
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20061030105648-kfd50jram0rzbtlo
Tags: upstream-7.15.5
ImportĀ upstreamĀ versionĀ 7.15.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
47
47
<p class="level0">curl_multi_socket - reads/writes available data <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
48
48
<p class="level0">#include &lt;curl/curl.h&gt; 
49
 
<p class="level0">CURLMcode curl_multi_socket(CURLM * multi_handle, curl_socket_t sockfd); 
50
 
<p class="level0">CURLMcode curl_multi_socket_all(CURLM *multi_handle); <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
51
 
<p class="level0">Alternative versions of <span Class="emphasis">curl_multi_perform()</span> that allows the application to pass in one of the file descriptors/sockets that have been detected to have "action" on them 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_perform()</span> with the <span Class="bold">sockfd</span> argument set to the socket with the action. 
52
 
<p class="level0">These functions inform the application about updates in the socket (file descriptor) status by doing none, one or multiple calls to the curl_socket_callback given 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. 
53
 
<p class="level0">If you want to force libcurl to (re-)check all its internal sockets and transfers instead of just a single one, you call <a class="bold" href="./curl_multi_socket_all.html">curl_multi_socket_all(3)</a> instead. 
54
 
<p class="level0">An application should call <a class="bold" href="./curl_multi_timeout.html">curl_multi_timeout(3)</a> to figure out how long it should 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. 
 
49
<p class="level0">CURLMcode curl_multi_socket(CURLM * multi_handle, curl_socket_t sockfd, &nbsp;                           int *running_handles); 
 
50
<p class="level0">CURLMcode curl_multi_socket_all(CURLM *multi_handle, &nbsp;                               int *running_handles); <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
 
51
<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 one of the file descriptors/sockets that have been detected to have "action" on them 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 <a class="emphasis" href="./curl_multi_socket.html">curl_multi_socket(3)</a> with the <span Class="bold">sockfd</span> argument set to the socket with the action. 
 
52
<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 <a class="emphasis" href="./curl_multi_socket.html">curl_multi_socket(3)</a> 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. 
 
53
<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. 
 
54
<p class="level0">To force libcurl to (re-)check all its internal sockets and transfers instead of just a single one, you call <a class="bold" href="./curl_multi_socket_all.html">curl_multi_socket_all(3)</a>. This is typically done as the first function call before the application has any knowledge about what sockets libcurl uses. 
 
55
<p class="level0">Applications should call <a class="bold" href="./curl_multi_timeout.html">curl_multi_timeout(3)</a> to figure out 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. 
 
56
<p class="level0"><a name="CALLBACK"></a><h2 class="nroffsh">CALLBACK DETAILS</h2>
 
57
<p class="level0">
55
58
<p class="level0">The socket <span Class="bold">callback</span> function uses a prototype like this <pre>
56
 
<p class="level0"><p class="level0">&nbsp;    int curl_socket_callback(CURL *easy,      /* easy handle */
57
 
 &nbsp;                             curl_socket_t s, /* socket */
58
 
 &nbsp;                             int action,      /* see values below */
59
 
 &nbsp;                             void *userp);    /* "private" pointer */
 
59
<p class="level0"><p class="level0">&nbsp; int curl_socket_callback(CURL *easy,      /* easy handle */
 
60
 &nbsp;                          curl_socket_t s, /* socket */
 
61
 &nbsp;                          int action,      /* see values below */
 
62
 &nbsp;                          void *userp,    /* private callback pointer */
 
63
 &nbsp;                          void *socketp); /* private socket pointer */
60
64
 <p class="level0">The callback MUST return 0.
61
 
 <p class="level0">The <span Class="emphasis">action</span> (third) argument to the callback has one of five values:
 
65
 <p class="level0">The <span Class="emphasis">easy</span> argument is a pointer to the easy handle that deals with this
 
66
 particular socket. Note that a single handle may work with several sockets
 
67
 simultaneously.
 
68
 <p class="level0">The <span Class="emphasis">s</span> argument is the actual socket value as you use it within your
 
69
 system.
 
70
 <p class="level0">The <span Class="emphasis">action</span> argument to the callback has one of five values:
62
71
 <p class="level1"><p class="level0"><a name="CURLPOLLNONE"></a><span class="nroffip">CURL_POLL_NONE (0)</span> <p class="level1">register, not interested in readiness (yet)
63
72
 <p class="level0"><a name="CURLPOLLIN"></a><span class="nroffip">CURL_POLL_IN (1)</span> <p class="level1">register, interested in read readiness
64
73
 <p class="level0"><a name="CURLPOLLOUT"></a><span class="nroffip">CURL_POLL_OUT (2)</span> <p class="level1">register, interested in write readiness
65
74
 <p class="level0"><a name="CURLPOLLINOUT"></a><span class="nroffip">CURL_POLL_INOUT (3)</span> <p class="level1">register, interested in both read and write readiness
66
75
 <p class="level0"><a name="CURLPOLLREMOVE"></a><span class="nroffip">CURL_POLL_REMOVE (4)</span> <p class="level1">deregister
67
 
 <p class="level0"></pre>
 
76
 <p class="level0"><p class="level0">The <span Class="emphasis">socketp</span> argument is a private pointer you have previously set with
 
77
 <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
 
78
 pointer has been set, socketp will be NULL. This argument is of course a
 
79
 service to applications that want to keep certain data or structs that are
 
80
 strictly associated to the given socket.
 
81
 <p class="level0">The <span Class="emphasis">userp</span> argument is a private pointer you have previously set with
 
82
 <a class="emphasis" href="./curl_multi_setopt.html">curl_multi_setopt(3)</a> and the CURLMOPT_SOCKETDATA option.
 
83
 </pre>
68
84
<a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
69
85
<p class="level0">CURLMcode type, general libcurl multi interface error code. 
70
86
<p class="level0">If you receive <span Class="emphasis">CURLM_CALL_MULTI_PERFORM</span>, this basically means that you should call <span Class="emphasis">curl_multi_perform</span> 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". 
78
94
<p class="level0">7. Wait for action on any of libcurl's sockets 
79
95
<p class="level0">8, When action happens, call curl_multi_socket() for the socket(s) that got action. 
80
96
<p class="level0">9. Go back to step 6. <a name="AVAILABILITY"></a><h2 class="nroffsh">AVAILABILITY</h2>
81
 
<p class="level0">This function was added in libcurl 7.16.0 <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
 
97
<p class="level0">This function was added in libcurl 7.15.4, although not deemed stable yet. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
82
98
<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> <p class="roffit">
83
99
 This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
84
100
</body></html>