curl_multi_add_handle.3 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. .\" generated by cd2nroff 0.1 from curl_multi_add_handle.md
  2. .TH curl_multi_add_handle 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_multi_add_handle \- add an easy handle to a multi session
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *easy_handle);
  9. .fi
  10. .SH DESCRIPTION
  11. Adds the \fIeasy handle\fP to the \fImulti_handle\fP.
  12. While an easy handle is added to a multi stack, you cannot and you must not
  13. use \fIcurl_easy_perform(3)\fP on that handle. After having removed the easy
  14. handle from the multi stack again, it is perfectly fine to use it with the
  15. easy interface again.
  16. If the easy handle is not set to use a shared (\fICURLOPT_SHARE(3)\fP) cache,
  17. it is made to use a DNS cache that is shared between all easy handles within
  18. the multi handle when \fIcurl_multi_add_handle(3)\fP is called.
  19. When an easy interface is added to a multi handle, it is set to use a shared
  20. connection cache owned by the multi handle. Removing and adding new easy
  21. handles does not affect the pool of connections or the ability to do
  22. connection reuse.
  23. If you have \fICURLMOPT_TIMERFUNCTION(3)\fP set in the multi handle (as you
  24. should if you are working event\-based with \fIcurl_multi_socket_action(3)\fP
  25. and friends), that callback is called from within this function to ask for an
  26. updated timer so that your main event loop gets the activity on this handle to
  27. get started.
  28. The easy handle remains added to the multi handle until you remove it again
  29. with \fIcurl_multi_remove_handle(3)\fP \- even when a transfer with that
  30. specific easy handle is completed.
  31. You should remove the easy handle from the multi stack before you terminate
  32. first the easy handle and then the multi handle:
  33. 1 \- \fIcurl_multi_remove_handle(3)\fP
  34. 2 \- \fIcurl_easy_cleanup(3)\fP
  35. 3 \- \fIcurl_multi_cleanup(3)\fP
  36. .SH PROTOCOLS
  37. This functionality affects all supported protocols
  38. .SH EXAMPLE
  39. .nf
  40. int main(void)
  41. {
  42. /* init a multi stack */
  43. CURLM *multi = curl_multi_init();
  44. /* create two easy handles */
  45. CURL *http_handle = curl_easy_init();
  46. CURL *http_handle2 = curl_easy_init();
  47. /* add individual transfers */
  48. curl_multi_add_handle(multi, http_handle);
  49. curl_multi_add_handle(multi, http_handle2);
  50. }
  51. .fi
  52. .SH AVAILABILITY
  53. Added in curl 7.9.6
  54. .SH RETURN VALUE
  55. CURLMcode type, general libcurl multi interface error code.
  56. .SH SEE ALSO
  57. .BR curl_multi_cleanup (3),
  58. .BR curl_multi_get_handles (3),
  59. .BR curl_multi_init (3),
  60. .BR curl_multi_setopt (3),
  61. .BR curl_multi_socket_action (3)