curl_multi_remove_handle.md (2064B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_multi_remove_handle 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_multi_add_handle (3) 9 - curl_multi_cleanup (3) 10 - curl_multi_init (3) 11 Protocol: 12 - All 13 Added-in: 7.9.6 14 --- 15 16 # NAME 17 18 curl_multi_remove_handle - remove an easy handle from a multi session 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *easy_handle); 26 ~~~ 27 28 # DESCRIPTION 29 30 Removes a given *easy_handle* from the *multi_handle*. This makes the 31 specified easy handle be removed from this multi handle's control. 32 33 When the easy handle has been removed from a multi stack, it is again 34 perfectly legal to invoke curl_easy_perform(3) on this easy handle. 35 36 Removing an easy handle while being in use is perfectly legal and effectively 37 halts the transfer in progress involving that easy handle. All other easy 38 handles and transfers remain unaffected. 39 40 It is fine to remove a handle at any time during a transfer, just not from 41 within any libcurl callback function. 42 43 Removing an easy handle from the multi handle before the corresponding 44 transfer is complete might cause libcurl to close the connection - if the 45 state of it and the internal protocol handler deem it necessary. Otherwise 46 libcurl keeps the connection alive in the connection pool associated with the 47 multi handle, ready to get reused for a future transfer using this multi 48 handle. 49 50 # %PROTOCOLS% 51 52 # EXAMPLE 53 54 ~~~c 55 int main(void) 56 { 57 CURLM *multi = curl_multi_init(); 58 int queued = 0; 59 60 /* when an easy handle has completed, remove it */ 61 CURLMsg *msg = curl_multi_info_read(multi, &queued); 62 if(msg) { 63 if(msg->msg == CURLMSG_DONE) { 64 /* a transfer ended */ 65 fprintf(stderr, "Transfer completed\n"); 66 curl_multi_remove_handle(multi, msg->easy_handle); 67 } 68 } 69 } 70 ~~~ 71 72 # %AVAILABILITY% 73 74 # RETURN VALUE 75 76 This function returns a CURLMcode indicating success or error. 77 78 CURLM_OK (0) means everything was OK, non-zero means an error occurred, see 79 libcurl-errors(3).