Install curl-7.19.5.tar.bz2
[msysgit/bosko.git] / mingw / share / man / man3 / curl_multi_socket.3
blob4f96c7caad9107ee853e0bf4a590c07a4e11d257
1 .\" $Id: curl_multi_socket.3,v 1.16 2009-05-11 20:32:51 bagder Exp $
2 .\"
3 .TH curl_multi_socket 3 "9 Jul 2006" "libcurl 7.16.0" "libcurl Manual"
4 .SH NAME
5 curl_multi_socket \- reads/writes available data
6 .SH SYNOPSIS
7 .nf
8 #include <curl/curl.h>
9 CURLMcode curl_multi_socket(CURLM * multi_handle, curl_socket_t sockfd,
10                             int *running_handles);
12 CURLMcode curl_multi_socket_all(CURLM *multi_handle,
13                                 int *running_handles);
14 .fi
15 .SH DESCRIPTION
16 These functions are deprecated. Do not use! See
17 \fIcurl_multi_socket_action(3)\fP instead!
19 At return, the integer \fBrunning_handles\fP points to will contain the number
20 of still running easy handles within the multi handle. When this number
21 reaches zero, all transfers are complete/done. Note that when you call
22 \fIcurl_multi_socket_action(3)\fP on a specific socket and the counter
23 decreases by one, it DOES NOT necessarily mean that this exact socket/transfer
24 is the one that completed. Use \fIcurl_multi_info_read(3)\fP to figure out
25 which easy handle that completed.
27 The \fBcurl_multi_socket_action(3)\fP functions inform the application about
28 updates in the socket (file descriptor) status by doing none, one, or multiple
29 calls to the socket callback function set with the CURLMOPT_SOCKETFUNCTION
30 option to \fIcurl_multi_setopt(3)\fP. They update the status with changes
31 since the previous time the callback was called.
33 Get the timeout time by setting the \fICURLMOPT_TIMERFUNCTION\fP option with
34 \fIcurl_multi_setopt(3)\fP. Your application will then get called with
35 information on how long to wait for socket actions at most before doing the
36 timeout action: call the \fBcurl_multi_socket_action(3)\fP function with the
37 \fBsockfd\fP argument set to CURL_SOCKET_TIMEOUT. You can also use the
38 \fIcurl_multi_timeout(3)\fP function to poll the value at any given time, but
39 for an event-based system using the callback is far better than relying on
40 polling the timeout value.
42 Usage of \fIcurl_multi_socket(3)\fP is deprecated, whereas the function is
43 equivalent to \fIcurl_multi_socket_action(3)\fP with \fBev_bitmask\fP set to
46 Force libcurl to (re-)check all its internal sockets and transfers instead of
47 just a single one by calling \fBcurl_multi_socket_all(3)\fP. Note that there
48 should not be any reason to use this function!
49 .SH "CALLBACK DETAILS"
51 The socket \fBcallback\fP function uses a prototype like this
52 .nf
54   int curl_socket_callback(CURL *easy,      /* easy handle */
55                            curl_socket_t s, /* socket */
56                            int action,      /* see values below */
57                            void *userp,    /* private callback pointer */
58                            void *socketp); /* private socket pointer */
60 .fi
61 The callback MUST return 0.
63 The \fIeasy\fP argument is a pointer to the easy handle that deals with this
64 particular socket. Note that a single handle may work with several sockets
65 simultaneously.
67 The \fIs\fP argument is the actual socket value as you use it within your
68 system.
70 The \fIaction\fP argument to the callback has one of five values:
71 .RS
72 .IP "CURL_POLL_NONE (0)"
73 register, not interested in readiness (yet)
74 .IP "CURL_POLL_IN (1)"
75 register, interested in read readiness
76 .IP "CURL_POLL_OUT (2)"
77 register, interested in write readiness
78 .IP "CURL_POLL_INOUT (3)"
79 register, interested in both read and write readiness
80 .IP "CURL_POLL_REMOVE (4)"
81 unregister
82 .RE
84 The \fIsocketp\fP argument is a private pointer you have previously set with
85 \fIcurl_multi_assign(3)\fP to be associated with the \fIs\fP socket. If no
86 pointer has been set, socketp will be NULL. This argument is of course a
87 service to applications that want to keep certain data or structs that are
88 strictly associated to the given socket.
90 The \fIuserp\fP argument is a private pointer you have previously set with
91 \fIcurl_multi_setopt(3)\fP and the CURLMOPT_SOCKETDATA option.
92 .SH "RETURN VALUE"
93 CURLMcode type, general libcurl multi interface error code.
95 Legacy: If you receive \fICURLM_CALL_MULTI_PERFORM\fP, this basically means
96 that you should call \fIcurl_multi_socket(3)\fP again, before you wait for
97 more actions on libcurl's sockets. You don't have to do it immediately, but
98 the return code means that libcurl may have more data available to return or
99 that there may be more data to send off before it is "satisfied".
101 In modern libcurls, \fICURLM_CALL_MULTI_PERFORM\fP or
102 \fICURLM_CALL_MULTI_SOKCET\fP should not be returned and no application needs
103 to care about them.
105 NOTE that the return code is for the whole multi stack. Problems still might have
106 occurred on individual transfers even when one of these functions
107 return OK.
108 .SH "TYPICAL USAGE"
109 1. Create a multi handle
111 2. Set the socket callback with CURLMOPT_SOCKETFUNCTION
113 3. Set the timeout callback with CURLMOPT_TIMERFUNCTION, to get to know what
114 timeout value to use when waiting for socket activities.
116 4. Add easy handles with curl_multi_add_handle()
118 5. Provide some means to manage the sockets libcurl is using, so you can check
119 them for activity. This can be done through your application code, or by way
120 of an external library such as libevent or glib.
122 6. Wait for activity on any of libcurl's sockets, use the timeout value your
123 callback has been told
125 7, When activity is detected, call curl_multi_socket_action() for the
126 socket(s) that got action. If no activity is detected and the timeout expires,
127 call \fIcurl_multi_socket_action(3)\fP with \fICURL_SOCKET_TIMEOUT\fP
129 8. Go back to step 6.
130 .SH AVAILABILITY
131 This function was added in libcurl 7.15.4, and is deemed stable since
132 7.16.0.
134 \fIcurl_multi_socket(3)\fP is deprecated, use
135 \fIcurl_multi_socket_action(3)\fP instead!
136 .SH "SEE ALSO"
137 .BR curl_multi_cleanup "(3), " curl_multi_init "(3), "
138 .BR curl_multi_fdset "(3), " curl_multi_info_read "(3), "
139 .BR "the hiperfifo.c example"