<pclass="level0">libcurl-share - how to use the share interface <aname="DESCRIPTION"></a><h2class="nroffsh">DESCRIPTION</h2>
<pclass="level0">This is an overview on how to use the libcurl share interface in your C programs. There are specific man pages for each function mentioned in here.
<pclass="level0">All functions in the share interface are prefixed with curl_share.
<pclass="level0">The share interface was added to enable sharing of data between curl "handles". <aname="ONE"></a><h2class="nroffsh">ONE SET OF DATA - MANY TRANSFERS</h2>
<pclass="level0">You can have multiple easy handles share data between them. Have them update and use the <spanClass="bold">same</span> cookie database or DNS cache! This way, each single transfer will take advantage from data updates made by the other transfer(s). <aname="SHARE"></a><h2class="nroffsh">SHARE OBJECT</h2>
<pclass="level0">You create a shared object with <aclass="emphasis"href="./curl_share_init.html">curl_share_init(3)</a>. It returns a handle for a newly created one.
<pclass="level0">You tell the shared object what data you want it to share by using <aclass="emphasis"href="./curl_share_setopt.html">curl_share_setopt(3)</a>. Currently you can only share DNS and/or COOKIE data.
<pclass="level0">Since you can use this share from multiple threads, and libcurl has no internal thread synchronization, you must provide mutex callbacks if you're using this multi-threaded. You set lock and unlock functions with <aclass="emphasis"href="./curl_share_setopt.html">curl_share_setopt(3)</a> too.
<pclass="level0">Then, you make an easy handle to use this share, you set the <spanClass="emphasis">CURLOPT_SHARE</span> option with <aclass="emphasis"href="./curl_easy_setopt.html">curl_easy_setopt(3)</a>, and pass in share handle. You can make any number of easy handles share the same share handle.
<pclass="level0">To make an easy handle stop using that particular share, you set <spanClass="emphasis">CURLOPT_SHARE</span> to NULL for that easy handle. To make a handle stop sharing a particular data, you can <spanClass="emphasis">CURLSHOPT_UNSHARE</span> it.
<pclass="level0">When you're done using the share, make sure that no easy handle is still using it, and call <aclass="emphasis"href="./curl_share_cleanup.html">curl_share_cleanup(3)</a> on the handle. <aname="SEE"></a><h2class="nroffsh">SEE ALSO</h2>