CURLSHOPT_SHARE.3 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. .\" generated by cd2nroff 0.1 from CURLSHOPT_SHARE.md
  2. .TH CURLSHOPT_SHARE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLSHOPT_SHARE \- add data to share
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_SHARE, long type);
  9. .fi
  10. .SH DESCRIPTION
  11. The \fItype\fP parameter specifies what specific data that should be shared
  12. and kept in the share object that was created with \fIcurl_share_init(3)\fP.
  13. The given \fItype\fP must be one of the values described below. You can set
  14. \fICURLSHOPT_SHARE(3)\fP multiple times with different data arguments to have
  15. the share object share multiple types of data. Unset a type again by setting
  16. \fICURLSHOPT_UNSHARE(3)\fP.
  17. .IP CURL_LOCK_DATA_COOKIE
  18. Cookie data is shared across the easy handles using this shared object. Note
  19. that this does not activate an easy handle\(aqs cookie handling. You can do that
  20. separately by using \fICURLOPT_COOKIEFILE(3)\fP for example.
  21. It is not supported to share cookies between multiple concurrent threads.
  22. .IP CURL_LOCK_DATA_DNS
  23. Cached DNS hosts are shared across the easy handles using this shared
  24. object. Note that when you use the multi interface, all easy handles added to
  25. the same multi handle share DNS cache by default without using this option.
  26. .IP CURL_LOCK_DATA_SSL_SESSION
  27. SSL session IDs are shared across the easy handles using this shared
  28. object. This reduces the time spent in the SSL handshake when reconnecting to
  29. the same server. Note SSL session IDs are reused within the same easy handle
  30. by default. Note this symbol was added in 7.10.3 but was not implemented until
  31. 7.23.0.
  32. It is not supported to share SSL sessions between multiple concurrent threads.
  33. .IP CURL_LOCK_DATA_CONNECT
  34. Put the connection cache in the share object and make all easy handles using
  35. this share object share the connection cache.
  36. It is not supported to share connections between multiple concurrent threads.
  37. Connections that are used for HTTP/2 or HTTP/3 multiplexing only get
  38. additional transfers added to them if the existing connection is held by the
  39. same multi or easy handle. libcurl does not support doing multiplexed streams
  40. in different threads using a shared connection.
  41. Support for \fBCURL_LOCK_DATA_CONNECT\fP was added in 7.57.0, but the symbol
  42. existed before this.
  43. Note that when you use the multi interface, all easy handles added to the same
  44. multi handle shares connection cache by default without using this option.
  45. .IP CURL_LOCK_DATA_PSL
  46. The Public Suffix List stored in the share object is made available to all
  47. easy handle bound to the later. Since the Public Suffix List is periodically
  48. refreshed, this avoids updates in too many different contexts.
  49. Added in 7.61.0.
  50. Note that when you use the multi interface, all easy handles added to the same
  51. multi handle shares PSL cache by default without using this option.
  52. .IP CURL_LOCK_DATA_HSTS
  53. The in\-memory HSTS cache.
  54. It is not supported to share the HSTS between multiple concurrent threads.
  55. Added in 7.88.0
  56. .SH PROTOCOLS
  57. This functionality affects all supported protocols
  58. .SH EXAMPLE
  59. .nf
  60. int main(void)
  61. {
  62. CURLSHcode sh;
  63. CURLSH *share = curl_share_init();
  64. sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  65. if(sh)
  66. printf("Error: %s\\n", curl_share_strerror(sh));
  67. }
  68. .fi
  69. .SH AVAILABILITY
  70. Added in curl 7.10.3
  71. .SH RETURN VALUE
  72. CURLSHE_OK (zero) means that the option was set properly, non\-zero means an
  73. error occurred. See \fIlibcurl\-errors(3)\fP for the full list with
  74. descriptions.
  75. .SH SEE ALSO
  76. .BR CURLSHOPT_UNSHARE (3),
  77. .BR curl_share_cleanup (3),
  78. .BR curl_share_init (3),
  79. .BR curl_share_setopt (3)