libcurl-share.3 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH libcurl-share 3 "8 Aug 2003" "libcurl 7.10.7" "libcurl share interface"
  25. .SH NAME
  26. libcurl-share \- how to use the share interface
  27. .SH DESCRIPTION
  28. This is an overview on how to use the libcurl share interface in your C
  29. programs. There are specific man pages for each function mentioned in
  30. here.
  31. All functions in the share interface are prefixed with curl_share.
  32. .SH "OBJECTIVES"
  33. The share interface was added to enable sharing of data between curl
  34. \&"handles".
  35. .SH "ONE SET OF DATA - MANY TRANSFERS"
  36. You can have multiple easy handles share data between them. Have them update
  37. and use the \fBsame\fP cookie database, DNS cache, TLS session cache and/or
  38. connection cache! This way, each single transfer will take advantage from data
  39. updates made by the other transfer(s).
  40. .SH "SHARE OBJECT"
  41. You create a shared object with \fIcurl_share_init(3)\fP. It returns a handle
  42. for a newly created one.
  43. You tell the shared object what data you want it to share by using
  44. \fIcurl_share_setopt(3)\fP.
  45. Since you can use this share from multiple threads, and libcurl has no
  46. internal thread synchronization, you must provide mutex callbacks if you are
  47. using this multi-threaded. You set lock and unlock functions with
  48. \fIcurl_share_setopt(3)\fP too.
  49. Then, you make an easy handle to use this share, you set the
  50. \fICURLOPT_SHARE(3)\fP option with \fIcurl_easy_setopt(3)\fP, and pass in
  51. share handle. You can make any number of easy handles share the same share
  52. handle.
  53. To make an easy handle stop using that particular share, you set
  54. \fICURLOPT_SHARE(3)\fP to NULL for that easy handle. To make a handle stop
  55. sharing a particular data, you can \fICURLSHOPT_UNSHARE\fP it.
  56. When you are done using the share, make sure that no easy handle is still using
  57. it, and call \fIcurl_share_cleanup(3)\fP on the handle.
  58. .SH "SEE ALSO"
  59. .BR curl_share_init "(3), " curl_share_setopt "(3), " curl_share_cleanup "(3)"
  60. .BR libcurl-errors "(3), " libcurl-easy "(3), " libcurl-multi "(3) "