1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: libcurl-share 5Section: 3 6Source: libcurl 7See-also: 8 - curl_share_cleanup (3) 9 - curl_share_init (3) 10 - curl_share_setopt (3) 11 - libcurl-easy (3) 12 - libcurl-errors (3) 13 - libcurl-multi (3) 14Protocol: 15 - All 16Added-in: n/a 17--- 18 19# NAME 20 21libcurl-share - how to use the share interface 22 23# DESCRIPTION 24 25This is an overview on how to use the libcurl share interface in your C 26programs. There are specific man pages for each function mentioned in 27here. 28 29All functions in the share interface are prefixed with curl_share. 30 31# OBJECTIVES 32 33The share interface was added to enable sharing of data between curl handles. 34 35# ONE SET OF DATA - MANY TRANSFERS 36 37You can have multiple easy handles share data between them. Have them update 38and use the **same** cookie database, DNS cache, TLS session cache and/or 39connection cache. This way, each single transfer takes advantage from data 40updates made by the other transfer(s). 41 42# SHARE OBJECT 43 44You create a shared object with curl_share_init(3). It returns a handle 45for a newly created one. 46 47You tell the shared object what data you want it to share by using 48curl_share_setopt(3). 49 50Since you can use this share from multiple threads, and libcurl has no 51internal thread synchronization, you must provide mutex callbacks if you are 52using this multi-threaded. You set lock and unlock functions with 53curl_share_setopt(3) too. 54 55Then, you make an easy handle to use this share, you set the 56CURLOPT_SHARE(3) option with curl_easy_setopt(3), and pass in 57share handle. You can make any number of easy handles share the same share 58handle. 59 60To make an easy handle stop using that particular share, you set 61CURLOPT_SHARE(3) to NULL for that easy handle. To make a handle stop 62sharing a particular data, you can CURLSHOPT_UNSHARE(3) it. 63 64When you are done using the share, make sure that no easy handle is still using 65it, and call curl_share_cleanup(3) on the handle. 66