libcurl-share(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… libcurl-share(3) β€” the libcurl share interface

Okay bestie, this is the libcurl share interface manual, and we're gonna make it make sense. No cap.

✨ NAME ✨

libcurl-share β€” how to use the share interface. That's the whole name vibe. Periodt.

🌸 DESCRIPTION 🌸

This is your overview of how to use the libcurl share interface inside your C programs. Every function mentioned in here has its own specific man page, so go get the deep lore there. Iykyk.

All functions in the share interface are prefixed with curl_share. Slay, consistent naming.

πŸ¦‹ OBJECTIVES πŸ¦‹

The share interface was added to enable sharing of data between curl "handles". That's the goal. Main character energy for shared data.

πŸŽ€ ONE SET OF DATA - MANY TRANSFERS πŸŽ€

You can have multiple easy handles share data between them. Have them update and use the same cookie database, DNS cache, TLS session cache and/or connection cache! This way, each single transfer will take advantage from data updates made by the other transfer(s). Literally teamwork.

πŸ‘‘ SHARE OBJECT πŸ‘‘

You create a shared object with curl_share_init(3). It returns a handle for a newly created one. Cute.

You tell the shared object what data you want it to share by using curl_share_setopt(3).

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 curl_share_setopt(3) too. This part is not optional if you're threadingβ€”respect the mutex, bestie.

Then, you make an easy handle use this share: you set the CURLOPT_SHARE(3) option with curl_easy_setopt(3), and pass in the share handle. You can make any number of easy handles share the same share handle. The more the merrier.

To make an easy handle stop using that particular share, you set CURLOPT_SHARE(3) to NULL for that easy handle. To make a handle stop sharing a particular data, you can CURLSHOPT_UNSHARE it.

When you're done using the share, make sure that no easy handle is still using it, and call curl_share_cleanup(3) on the handle. Cleanup era, but only after everyone's out. πŸ’€

πŸ’– SEE ALSO πŸ’–


πŸ’– cute sign-off: this page is from libcurl 7.10.7, dated 8 Aug 2003, and it's literally libcurl-share(3). Bye bestie, go share responsibly! 🫢

πŸ“¦ where this page comes from