1*6236dae4SAndroid Build Coastguard Worker--- 2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 4*6236dae4SAndroid Build Coastguard WorkerTitle: libcurl-share 5*6236dae4SAndroid Build Coastguard WorkerSection: 3 6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl 7*6236dae4SAndroid Build Coastguard WorkerSee-also: 8*6236dae4SAndroid Build Coastguard Worker - curl_share_cleanup (3) 9*6236dae4SAndroid Build Coastguard Worker - curl_share_init (3) 10*6236dae4SAndroid Build Coastguard Worker - curl_share_setopt (3) 11*6236dae4SAndroid Build Coastguard Worker - libcurl-easy (3) 12*6236dae4SAndroid Build Coastguard Worker - libcurl-errors (3) 13*6236dae4SAndroid Build Coastguard Worker - libcurl-multi (3) 14*6236dae4SAndroid Build Coastguard WorkerProtocol: 15*6236dae4SAndroid Build Coastguard Worker - All 16*6236dae4SAndroid Build Coastguard WorkerAdded-in: n/a 17*6236dae4SAndroid Build Coastguard Worker--- 18*6236dae4SAndroid Build Coastguard Worker 19*6236dae4SAndroid Build Coastguard Worker# NAME 20*6236dae4SAndroid Build Coastguard Worker 21*6236dae4SAndroid Build Coastguard Workerlibcurl-share - how to use the share interface 22*6236dae4SAndroid Build Coastguard Worker 23*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION 24*6236dae4SAndroid Build Coastguard Worker 25*6236dae4SAndroid Build Coastguard WorkerThis is an overview on how to use the libcurl share interface in your C 26*6236dae4SAndroid Build Coastguard Workerprograms. There are specific man pages for each function mentioned in 27*6236dae4SAndroid Build Coastguard Workerhere. 28*6236dae4SAndroid Build Coastguard Worker 29*6236dae4SAndroid Build Coastguard WorkerAll functions in the share interface are prefixed with curl_share. 30*6236dae4SAndroid Build Coastguard Worker 31*6236dae4SAndroid Build Coastguard Worker# OBJECTIVES 32*6236dae4SAndroid Build Coastguard Worker 33*6236dae4SAndroid Build Coastguard WorkerThe share interface was added to enable sharing of data between curl handles. 34*6236dae4SAndroid Build Coastguard Worker 35*6236dae4SAndroid Build Coastguard Worker# ONE SET OF DATA - MANY TRANSFERS 36*6236dae4SAndroid Build Coastguard Worker 37*6236dae4SAndroid Build Coastguard WorkerYou can have multiple easy handles share data between them. Have them update 38*6236dae4SAndroid Build Coastguard Workerand use the **same** cookie database, DNS cache, TLS session cache and/or 39*6236dae4SAndroid Build Coastguard Workerconnection cache. This way, each single transfer takes advantage from data 40*6236dae4SAndroid Build Coastguard Workerupdates made by the other transfer(s). 41*6236dae4SAndroid Build Coastguard Worker 42*6236dae4SAndroid Build Coastguard Worker# SHARE OBJECT 43*6236dae4SAndroid Build Coastguard Worker 44*6236dae4SAndroid Build Coastguard WorkerYou create a shared object with curl_share_init(3). It returns a handle 45*6236dae4SAndroid Build Coastguard Workerfor a newly created one. 46*6236dae4SAndroid Build Coastguard Worker 47*6236dae4SAndroid Build Coastguard WorkerYou tell the shared object what data you want it to share by using 48*6236dae4SAndroid Build Coastguard Workercurl_share_setopt(3). 49*6236dae4SAndroid Build Coastguard Worker 50*6236dae4SAndroid Build Coastguard WorkerSince you can use this share from multiple threads, and libcurl has no 51*6236dae4SAndroid Build Coastguard Workerinternal thread synchronization, you must provide mutex callbacks if you are 52*6236dae4SAndroid Build Coastguard Workerusing this multi-threaded. You set lock and unlock functions with 53*6236dae4SAndroid Build Coastguard Workercurl_share_setopt(3) too. 54*6236dae4SAndroid Build Coastguard Worker 55*6236dae4SAndroid Build Coastguard WorkerThen, you make an easy handle to use this share, you set the 56*6236dae4SAndroid Build Coastguard WorkerCURLOPT_SHARE(3) option with curl_easy_setopt(3), and pass in 57*6236dae4SAndroid Build Coastguard Workershare handle. You can make any number of easy handles share the same share 58*6236dae4SAndroid Build Coastguard Workerhandle. 59*6236dae4SAndroid Build Coastguard Worker 60*6236dae4SAndroid Build Coastguard WorkerTo make an easy handle stop using that particular share, you set 61*6236dae4SAndroid Build Coastguard WorkerCURLOPT_SHARE(3) to NULL for that easy handle. To make a handle stop 62*6236dae4SAndroid Build Coastguard Workersharing a particular data, you can CURLSHOPT_UNSHARE(3) it. 63*6236dae4SAndroid Build Coastguard Worker 64*6236dae4SAndroid Build Coastguard WorkerWhen you are done using the share, make sure that no easy handle is still using 65*6236dae4SAndroid Build Coastguard Workerit, and call curl_share_cleanup(3) on the handle. 66