CURLSHOPT_SHARE(3) | Library Functions Manual | CURLSHOPT_SHARE(3) |
CURLSHOPT_SHARE - add data to share
#include <curl/curl.h> CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_SHARE, long type);
The type parameter specifies what specific data that should be shared and kept in the share object that was created with curl_share_init(3). The given type must be be one of the values described below. You can set CURLSHOPT_SHARE(3) multiple times with different data arguments to have the share object share multiple types of data. Unset a type again by setting CURLSHOPT_UNSHARE(3).
It is not supported to share connections between multiple concurrent threads.
Connections that are used for HTTP/1.1 Pipelining or HTTP/2 multiplexing only get additional transfers added to them if the existing connection is held by the same multi or easy handle. libcurl does not support doing HTTP/2 streams in different threads using a shared connection.
Support for CURL_LOCK_DATA_CONNECT was added in 7.57.0, but the symbol existed before this.
Note that when you use the multi interface, all easy handles added to the same multi handle shares connection cache by default without using this option.
Added in 7.61.0.
Note that when you use the multi interface, all easy handles added to the same multi handle shares PSL cache by default without using this option.
It is not supported to share the HSTS between multiple concurrent threads.
Added in 7.88.0
All
int main(void) {
CURLSHcode sh;
CURLSH *share = curl_share_init();
sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
if(sh)
printf("Error: %s\n", curl_share_strerror(sh)); }
Added in 7.10
CURLSHE_OK (zero) means that the option was set properly, non-zero means an error occurred. See libcurl-errors(3) for the full list with descriptions.
CURLSHOPT_UNSHARE(3), curl_share_cleanup(3), curl_share_init(3), curl_share_setopt(3)
March 12 2024 | libcurl |