curl_multi_setopt.md (3160B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_multi_setopt 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_multi_cleanup (3) 9 - curl_multi_info_read (3) 10 - curl_multi_init (3) 11 - curl_multi_socket (3) 12 Protocol: 13 - All 14 Added-in: 7.15.4 15 --- 16 17 # NAME 18 19 curl_multi_setopt - set options for a curl multi handle 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLMcode curl_multi_setopt(CURLM *multi, CURLMoption option, parameter); 27 ~~~ 28 29 # DESCRIPTION 30 31 curl_multi_setopt(3) is used to tell a libcurl multi handle how to behave. By 32 using the appropriate options to curl_multi_setopt(3), you can change 33 libcurl's behavior when using that multi handle. All options are set with the 34 *option* followed by the *parameter*. That parameter can be a **long**, a 35 **function pointer**, an **object pointer** or a **curl_off_t** type, 36 depending on what the specific option expects. Read this manual carefully as 37 bad input values may cause libcurl to behave badly. You can only set one 38 option in each function call. 39 40 # OPTIONS 41 42 ## CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE 43 44 **deprecated** See CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE(3) 45 46 ## CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE 47 48 **deprecated** See CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE(3) 49 50 ## CURLMOPT_MAXCONNECTS 51 52 Size of connection cache. See CURLMOPT_MAXCONNECTS(3) 53 54 ## CURLMOPT_MAX_CONCURRENT_STREAMS 55 56 Max concurrent streams for http2. See CURLMOPT_MAX_CONCURRENT_STREAMS(3) 57 58 ## CURLMOPT_MAX_HOST_CONNECTIONS 59 60 Max number of connections to a single host. See 61 CURLMOPT_MAX_HOST_CONNECTIONS(3) 62 63 ## CURLMOPT_MAX_PIPELINE_LENGTH 64 65 **deprecated**. See CURLMOPT_MAX_PIPELINE_LENGTH(3) 66 67 ## CURLMOPT_MAX_TOTAL_CONNECTIONS 68 69 Max simultaneously open connections. See CURLMOPT_MAX_TOTAL_CONNECTIONS(3) 70 71 ## CURLMOPT_PIPELINING 72 73 Enable HTTP multiplexing. See CURLMOPT_PIPELINING(3) 74 75 ## CURLMOPT_PIPELINING_SERVER_BL 76 77 **deprecated**. See CURLMOPT_PIPELINING_SERVER_BL(3) 78 79 ## CURLMOPT_PIPELINING_SITE_BL 80 81 **deprecated**. See CURLMOPT_PIPELINING_SITE_BL(3) 82 83 ## CURLMOPT_PUSHDATA 84 85 Pointer to pass to push callback. See CURLMOPT_PUSHDATA(3) 86 87 ## CURLMOPT_PUSHFUNCTION 88 89 Callback that approves or denies server pushes. See CURLMOPT_PUSHFUNCTION(3) 90 91 ## CURLMOPT_SOCKETDATA 92 93 Custom pointer passed to the socket callback. See CURLMOPT_SOCKETDATA(3) 94 95 ## CURLMOPT_SOCKETFUNCTION 96 97 Callback informed about what to wait for. See CURLMOPT_SOCKETFUNCTION(3) 98 99 ## CURLMOPT_TIMERDATA 100 101 Custom pointer to pass to timer callback. See CURLMOPT_TIMERDATA(3) 102 103 ## CURLMOPT_TIMERFUNCTION 104 105 Callback to receive timeout values. See CURLMOPT_TIMERFUNCTION(3) 106 107 # %PROTOCOLS% 108 109 # EXAMPLE 110 111 ~~~c 112 113 #define MAX_PARALLEL 45 114 115 int main(void) 116 { 117 CURLM *multi = curl_multi_init(); 118 119 /* Limit the amount of simultaneous connections curl should allow: */ 120 curl_multi_setopt(multi, CURLMOPT_MAXCONNECTS, (long)MAX_PARALLEL); 121 } 122 ~~~ 123 124 # %AVAILABILITY% 125 126 # RETURN VALUE 127 128 This function returns a CURLMcode indicating success or error. 129 130 CURLM_OK (0) means everything was OK, non-zero means an error occurred, see 131 libcurl-errors(3). 132 133 Note that it returns a CURLM_UNKNOWN_OPTION if you try setting an option that 134 this version of libcurl does not know of.