]> git.sven.stormbind.net Git - sven/tclcurl.git/blob - doc/tclcurl_multi.html
Imported Upstream version 7.19.6
[sven/tclcurl.git] / doc / tclcurl_multi.html
1 <HTML><HEAD><TITLE>Manpage of TclCurl</TITLE>
2 </HEAD><BODY>
3 <H1>TclCurl</H1>
4 Section: TclCurl Multi Interface (n)<BR>Updated: 8 September 2008<BR><HR>
5
6 <A NAME="lbAB">&nbsp;</A>
7 <H2>NAME</H2>
8
9 TclCurl: - get  a  URL with FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE or LDAP syntax.
10 <A NAME="lbAC">&nbsp;</A>
11 <H2>SYNOPSIS</H2>
12
13 <B>curl::multiinit</B>
14
15 <P>
16 <I>multiHandle</I><B> addhandle</B>
17
18 <P>
19 <I>multiHandle</I><B> removehandle</B>
20
21 <P>
22 <I>multiHandle</I><B> configure</B>
23
24 <P>
25 <I>multiHandle</I><B> perform</B>
26
27 <P>
28 <I>multiHandle</I><B> active</B>
29
30 <P>
31 <I>multiHandle</I><B> getinfo </B>
32
33 <P>
34 <I>multihandle</I><B> cleanup</B>
35
36 <P>
37 <I>multihandle</I><B> auto</B>
38
39 <P>
40 <B>curl::multistrerror </B><I>errorCode</I>
41
42 <P>
43 <A NAME="lbAD">&nbsp;</A>
44 <H2>DESCRIPTION</H2>
45
46 TclCurl's multi interface introduces several new abilities that the easy
47 interface refuses to offer. They are mainly:
48 <ul>
49 <li>Enable a &quot;pull&quot; interface. The application that uses TclCurl decides where
50 and when to get/send data.<br><br>
51 <li>Enable multiple simultaneous transfers in the same thread without making it
52 complicated for the application.<br><br>
53 <li>Keep Tk GUIs 'alive' while transfers are taking place.<br><br>
54 </ul>
55 <P>
56 </DL>
57 <A NAME="lbAE">&nbsp;</A>
58 <H2>Blocking</H2>
59
60 A few areas in the code are still using blocking code, even when used from the
61 multi interface. While we certainly want and intend for these to get fixed in
62 the future, you should be aware of the following current restrictions:
63 <ul>
64 <li>Name resolves on non-windows unless c-ares is used.</B>
65
66 <li>GnuTLS SSL connections.</B>
67
68 <li>Active FTP connections.</B>
69
70 <li>HTTP proxy CONNECT operations.</B>
71
72 <li>SCP and SFTP connections.</B>
73
74 <li>SFTP transfers.</B>
75
76 <li>TFTP transfers</B>
77
78 <li>file:// transfers.</B>
79 </ul>
80
81 <P>
82 <A NAME="lbAF">&nbsp;</A>
83 <H2>curl::multiinit</H2>
84
85 This procedure must be the first one to call, it returns a <I>multiHandle</I>
86 that you need to use to invoke TclCurl procedures. The init MUST have a
87 corresponding call to <I>cleanup</I> when the operation is completed.
88 <P>
89 <B>RETURN VALUE</B>
90
91 <P>
92 <I>multiHandle</I>
93
94 to use.
95 <P>
96 <A NAME="lbAG">&nbsp;</A>
97 <H2>multiHandle addhandle ?easyHandle?</H2>
98
99 <P>
100 Each single transfer is built up with an 'easy' handle, the kind we have been
101 using so far with TclCurl, you must create them and setup the appropriate
102 options for each of them. Then we add them to the 'multi stack' using the
103 <I>addhandle</I> command.
104 <P>
105 If the easy handle is not set to use a shared or global DNS cache, it will be made
106 to use the DNS cache that is shared between all easy handles within the multi handle.
107 <P>
108 When an easy handle has been added to a multi stack, you can not and you must not use
109 <I>perform</I> on that handle!
110 <P>
111 <P>
112 <I>multiHandle</I>
113
114 is the return code from the <I>curl::multiinit</I> call.
115 <P>
116 <B>RETURN VALUE</B>
117
118 The possible return values are:
119 <DL COMPACT>
120 <DT>-1<DD>
121 Handle added to the multi stack, please call
122 <I>perform</I>
123
124 soon
125 <DT>0<DD>
126 Handle added ok.
127 <DT>1<DD>
128 Invalid multi handle.
129 <DT>2<DD>
130 Invalid 'easy' handle. It could mean that it isn't an easy handle at all, or possibly that
131 the handle already is in used by this or another multi handle. 
132 <DT>3<DD>
133 Out of memory, you should never get this.
134 <DT>4<DD>
135 You found a bug in TclCurl.
136 <P>
137 </DL>
138 <A NAME="lbAH">&nbsp;</A>
139 <H2>multiHandle removehandle ?easyHandle?</H2>
140
141 <P>
142 When a transfer is done or if we want to stop a transfer before it is completed,
143 we can use the <I>removehandle</I> command. Once removed from the multi handle,
144 we can again use other easy interface functions on it.
145 <P>
146 Please note that when a single transfer is completed, the easy handle is still
147 left added to the multi stack. You need to remove it and then close or, possibly,
148 set new options to it and add it again to the multi handle to start another transfer.
149 <P>
150 <P>
151 <B>RETURN VALUE</B>
152
153 The possible return values are:
154 <DL COMPACT>
155 <DT>0<DD>
156 Handle removed ok.
157 <DT>1<DD>
158 Invalid multi handle.
159 <DT>2<DD>
160 Invalid 'easy' handle.
161 <DT>3<DD>
162 Out of memory, you should never get this.
163 <DT>4<DD>
164 You found a bug in TclCurl.
165 <P>
166 </DL>
167 <A NAME="lbAI">&nbsp;</A>
168 <H2>multiHandle configure</H2>
169
170 So far the only option is:
171 <DL COMPACT>
172 <DT><B>-pipelining</B>
173
174 <DD>
175 Pass a 1 to enable or 0 to disable. Enabling pipelining on a multi handle will
176 make it attempt to perform HTTP Pipelining as far as possible for transfers using
177 this handle. This means that if you add a second request that can use an already
178 existing connection, the second request will be &quot;piped&quot; on the same connection
179 rather than being executed in parallel.
180 <DT><B>-maxconnects</B>
181
182 <DD>
183 Pass a number which will be used as the maximum amount of simultaneously open
184 connections that TclCurl may cache. Default is 10, and TclCurl will enlarge
185 the size for each added easy handle to make it fit 4 times the number of added
186 easy handles.
187 <P>
188 By setting this option, you can prevent the cache size to grow beyond the limit
189 set by you. When the cache is full, curl closes the oldest one in the cache to
190 prevent the number of open connections to increase.
191 <P>
192 This option is for the multi handle's use only, when using the easy interface you should instead use it's own <B>maxconnects</B> option.
193 <P>
194 </DL>
195 <A NAME="lbAJ">&nbsp;</A>
196 <H2>multiHandle perform</H2>
197
198 Adding the easy handles to the multi stack does not start any transfer.
199 Remember that one of the main ideas with this interface is to let your
200 application drive. You drive the transfers by invoking
201 <I>perform.</I>
202
203 TclCurl will then transfer data if there is anything available to transfer.
204 It'll use the callbacks and everything else we have setup in the individual
205 easy handles. It'll transfer data on all current transfers in the multi stack
206 that are ready to transfer anything. It may be all, it may be none.
207 <P>
208 When you call <B>perform</B> and the amount of Irunning handles is
209 changed from the previous call (or is less than the amount of easy handles
210 you added to the multi handle), you know that there is one or more
211 transfers less &quot;running&quot;. You can then call <I>getinfo</I> to
212 get information about each individual completed transfer.
213 <P>
214 <B>RETURN VALUE</B>
215
216 If everything goes well, it returns the number of running handles, '0' if all
217 are done. In case of error, it will return the error code.
218 <P>
219 <A NAME="lbAK">&nbsp;</A>
220 <H2>multiHandle active</H2>
221
222 In order to know if any of the easy handles are ready to transfer data before
223 invoking
224 <I>perform</I>
225
226 you can use the
227 <I>active</I>
228
229 command, it will return the number of transfers currently active.
230 <P>
231 <B>RETURN VALUE</B>
232
233 The number of active transfers or '-1' in case of error.
234 <P>
235 <A NAME="lbAL">&nbsp;</A>
236 <H2>multiHandle getinfo</H2>
237
238 This procedure returns very simple information about the transfers, you
239 can get more detail information using the <I>getinfo</I>
240 command on each of the easy handles.
241 <P>
242 <P>
243 <B>RETURN VALUE</B>
244
245 A list with the following elements:
246 <DL COMPACT>
247 <DT>easyHandle about which the info is about.<DD>
248 <DT>state of the transfer, '1' if it is done.<DD>
249 <DT>exit code of the transfer, '0' if there was no error,...<DD>
250 <DT>Number of messages still in the info queue.<DD>
251 <DT>In case there are no messages in the queue it will return {&quot;&quot; 0 0 0}.<DD>
252 <P>
253 </DL>
254 <A NAME="lbAM">&nbsp;</A>
255 <H2>multiHandle cleanup</H2>
256
257 This procedure must be the last one to call for a multi stack, it is the opposite of the
258 <I>curl::multiinit</I>
259
260 procedure and must be called with the same
261 <I>multiHandle</I>
262
263 as input as the
264 <B>curl::multiinit</B>
265
266 call returned.
267 <P>
268 <A NAME="lbAN">&nbsp;</A>
269 <H2>multiHandle auto ?-command <I>command</I>?</H2>
270
271 Using this command Tcl's event loop will take care of periodically invoking <B>perform</B>
272 for you, before using it, you must have already added at least one easy handle to
273 the multi handle.
274 <P>
275 The <B>command</B> option allows you to specify a command to invoke after all the easy
276 handles have finished their transfers, even though I say it is an option, the truth is
277 you must use this command to cleanup all the handles, otherwise the transfered files
278 may not be complete.
279 <P>
280 This support is still in a very experimental state, it may still change without warning.
281 Any and all comments are welcome.
282 <P>
283 You can find a couple of examples at <B>tests/multi</B>.
284 <P>
285 <A NAME="lbAO">&nbsp;</A>
286 <H2>curl::multistrerror errorCode</H2>
287
288 This procedure returns a string describing the error code passed in the argument.
289 <P>
290 <A NAME="lbAP">&nbsp;</A>
291 <H2>SEE ALSO</H2>
292
293 <I>tclcurl, curl.</I>
294
295 <P>
296
297 <HR>
298 <A NAME="index">&nbsp;</A><H2>Index</H2>
299 <DL>
300 <DT><A HREF="#lbAB">NAME</A><DD>
301 <DT><A HREF="#lbAC">SYNOPSIS</A><DD>
302 <DT><A HREF="#lbAD">DESCRIPTION</A><DD>
303 <DT><A HREF="#lbAE">Blocking</A><DD>
304 <DT><A HREF="#lbAF">curl::multiinit</A><DD>
305 <DT><A HREF="#lbAG">multiHandle addhandle ?easyHandle?</A><DD>
306 <DT><A HREF="#lbAH">multiHandle removehandle ?easyHandle?</A><DD>
307 <DT><A HREF="#lbAI">multiHandle configure</A><DD>
308 <DT><A HREF="#lbAJ">multiHandle perform</A><DD>
309 <DT><A HREF="#lbAK">multiHandle active</A><DD>
310 <DT><A HREF="#lbAL">multiHandle getinfo</A><DD>
311 <DT><A HREF="#lbAM">multiHandle cleanup</A><DD>
312 <DT><A HREF="#lbAN">multiHandle auto ?-command <I>command</I>?</A><DD>
313 <DT><A HREF="#lbAO">curl::multistrerror errorCode</A><DD>
314 <DT><A HREF="#lbAP">SEE ALSO</A><DD>
315 </DL>
316 <HR>
317 This document was created by man2html, using the manual pages.<BR>
318 </BODY>
319 </HTML>