7debfd842411dae91691d3b416420f27d949a29e
[platform/upstream/curl.git] / docs / libcurl / curl_easy_pause.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
9 .\" *
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at http://curl.haxx.se/docs/copyright.html.
13 .\" *
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
17 .\" *
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
20 .\" *
21 .\" **************************************************************************
22 .TH curl_easy_pause 3 "17 Dec 2007" "libcurl 7.18.0" "libcurl Manual"
23 .SH NAME
24 curl_easy_pause - pause and unpause a connection
25 .SH SYNOPSIS
26 .B #include <curl/curl.h>
27
28 .BI "CURLcode curl_easy_pause(CURL *"handle ", int "bitmask " );"
29
30 .SH DESCRIPTION
31 Using this function, you can explicitly mark a running connection to get
32 paused, and you can unpause a connection that was previously paused.
33
34 A connection can be paused by using this function or by letting the read
35 or the write callbacks return the proper magic return code
36 (\fICURL_READFUNC_PAUSE\fP and \fICURL_WRITEFUNC_PAUSE\fP). A write callback
37 that returns pause signals to the library that it couldn't take care of any
38 data at all, and that data will then be delivered again to the callback when
39 the writing is later unpaused.
40
41 NOTE: while it may feel tempting, take care and notice that you cannot call
42 this function from another thread.
43
44 When this function is called to unpause reading, the chance is high that you
45 will get your write callback called before this function returns.
46
47 The \fBhandle\fP argument is of course identifying the handle that operates on
48 the connection you want to pause or unpause.
49
50 The \fBbitmask\fP argument is a set of bits that sets the new state of the
51 connection. The following bits can be used:
52 .IP CURLPAUSE_RECV
53 Pause receiving data. There will be no data received on this connection until
54 this function is called again without this bit set. Thus, the write callback
55 (\fICURLOPT_WRITEFUNCTION\fP) won't be called.
56 .IP CURLPAUSE_SEND
57 Pause sending data. There will be no data sent on this connection until this
58 function is called again without this bit set. Thus, the read callback
59 (\fICURLOPT_READFUNCTION\fP) won't be called.
60 .IP CURLPAUSE_ALL
61 Convenience define that pauses both directions.
62 .IP CURLPAUSE_CONT
63 Convenience define that unpauses both directions
64 .SH RETURN VALUE
65 CURLE_OK (zero) means that the option was set properly, and a non-zero return
66 code means something wrong occurred after the new state was set.  See the
67 \fIlibcurl-errors(3)\fP man page for the full list with descriptions.
68 .SH AVAILABILITY
69 This function was added in libcurl 7.18.0. Before this version, there was no
70 explicit support for pausing transfers.
71 .SH "USAGE WITH THE MULTI-SOCKET INTERFACE"
72 Before libcurl 7.32.0, when a specific handle was unpaused with this function,
73 there was no particular forced rechecking or similar of the socket's state,
74 which made the continuation of the transfer get delayed until next
75 multi-socket call invoke or even longer. Alternatively, the user could
76 forcibly call for example curl_multi_socket_all(3) - with a rather hefty
77 performance penalty.
78
79 Starting in libcurl 7.32.0, unpausing a transfer will schedule a timeout
80 trigger for that handle 1 millisecond into the future, so that a
81 curl_multi_socket_action( ... CURL_SOCKET_TIMEOUT) can be used immediately
82 afterwards to get the transfer going again as desired.
83 .SH "MEMORY USE"
84 When pausing a read by returning the magic return code from a write callback,
85 the read data is already in libcurl's internal buffers so it'll have to keep
86 it in an allocated buffer until the reading is again unpaused using this
87 function.
88
89 If the downloaded data is compressed and is asked to get uncompressed
90 automatically on download, libcurl will continue to uncompress the entire
91 downloaded chunk and it will cache the data uncompressed. This has the side-
92 effect that if you download something that is compressed a lot, it can result
93 in a very large data amount needing to be allocated to save the data during
94 the pause. This said, you should probably consider not using paused reading if
95 you allow libcurl to uncompress data automatically.
96 .SH "SEE ALSO"
97 .BR curl_easy_cleanup "(3), " curl_easy_reset "(3)"