1curl_easy_pause(3) libcurl Manual curl_easy_pause(3)
2
3
4
6 curl_easy_pause - pause and unpause a connection
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_pause(CURL *handle, int bitmask);
12
14 Using this function, you can explicitly mark a running connection to
15 get paused, and you can unpause a connection that was previously
16 paused.
17
18 A connection can be paused by using this function or by letting the
19 read or the write callbacks return the proper magic return code
20 (CURL_READFUNC_PAUSE and CURL_WRITEFUNC_PAUSE). A write callback that
21 returns pause signals to the library that it couldn't take care of any
22 data at all, and that data will then be delivered again to the callback
23 when the transfer is unpaused.
24
25 While it may feel tempting, take care and notice that you cannot call
26 this function from another thread. To unpause, you may for example call
27 it from the progress callback (CURLOPT_PROGRESSFUNCTION(3)), which gets
28 called at least once per second, even if the connection is paused.
29
30 When this function is called to unpause receiving, the chance is high
31 that you will get your write callback called before this function re‐
32 turns.
33
34 The handle argument identifies the transfer you want to pause or un‐
35 pause.
36
37 A paused transfer is excluded from low speed cancels via the CUR‐
38 LOPT_LOW_SPEED_LIMIT(3) option and unpausing a transfer will reset the
39 time period required for the low speed limit to be met.
40
41 The bitmask argument is a set of bits that sets the new state of the
42 connection. The following bits can be used:
43
44 CURLPAUSE_RECV
45 Pause receiving data. There will be no data received on this
46 connection until this function is called again without this bit
47 set. Thus, the write callback (CURLOPT_WRITEFUNCTION(3)) won't
48 be called.
49
50 CURLPAUSE_SEND
51 Pause sending data. There will be no data sent on this connec‐
52 tion until this function is called again without this bit set.
53 Thus, the read callback (CURLOPT_READFUNCTION(3)) won't be
54 called.
55
56 CURLPAUSE_ALL
57 Convenience define that pauses both directions.
58
59 CURLPAUSE_CONT
60 Convenience define that unpauses both directions.
61
63 CURLE_OK (zero) means that the option was set properly, and a non-zero
64 return code means something wrong occurred after the new state was set.
65 See the libcurl-errors(3) man page for the full list with descriptions.
66
68 The pausing of transfers does not work with protocols that work without
69 network connectivity, like FILE://. Trying to pause such a transfer, in
70 any direction, will cause problems in the worst case or an error in the
71 best case.
72
74 When a connection is used multiplexed, like for HTTP/2, and one of the
75 transfers over the connection is paused and the others continue flow‐
76 ing, libcurl might end up buffering contents for the paused transfer.
77 It has to do this because it needs to drain the socket for the other
78 transfers and the already announced window size for the paused transfer
79 will allow the server to continue sending data up to that window size
80 amount. By default, libcurl announces a 32 megabyte window size, which
81 thus can make libcurl end up buffering 32 megabyte of data for a paused
82 stream.
83
84 When such a paused stream is unpaused again, any buffered data will be
85 delivered first.
86
88 Added in libcurl 7.18.0.
89
91 When pausing a read by returning the magic return code from a write
92 callback, the read data is already in libcurl's internal buffers so
93 it'll have to keep it in an allocated buffer until the receiving is
94 again unpaused using this function.
95
96 If the downloaded data is compressed and is asked to get uncompressed
97 automatically on download, libcurl will continue to uncompress the en‐
98 tire downloaded chunk and it will cache the data uncompressed. This has
99 the side- effect that if you download something that is compressed a
100 lot, it can result in a very large data amount needing to be allocated
101 to save the data during the pause. This said, you should probably con‐
102 sider not using paused receiving if you allow libcurl to uncompress
103 data automatically.
104
106 curl_easy_cleanup(3), curl_easy_reset(3)
107
108
109
110libcurl 7.76.1 December 22, 2020 curl_easy_pause(3)