curl_multi_add_handle.3 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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 curl_multi_add_handle 3 "4 March 2002" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_multi_add_handle - add an easy handle to a multi session
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *easy_handle);
  31. .fi
  32. .SH DESCRIPTION
  33. Adds a standard easy handle to the multi stack. This function call will make
  34. this \fImulti_handle\fP control the specified \fIeasy_handle\fP.
  35. While an easy handle is added to a multi stack, you cannot and you must not
  36. use \fIcurl_easy_perform(3)\fP on that handle. After having removed the easy
  37. handle from the multi stack again, it is perfectly fine to use it with the
  38. easy interface again.
  39. If the easy handle is not set to use a shared (\fICURLOPT_SHARE(3)\fP) or
  40. global DNS cache (\fICURLOPT_DNS_USE_GLOBAL_CACHE(3)\fP), it will be made to
  41. use the DNS cache that is shared between all easy handles within the multi
  42. handle when \fIcurl_multi_add_handle(3)\fP is called.
  43. When an easy interface is added to a multi handle, it will use a shared
  44. connection cache owned by the multi handle. Removing and adding new easy
  45. handles will not affect the pool of connections or the ability to do
  46. connection re-use.
  47. If you have \fICURLMOPT_TIMERFUNCTION(3)\fP set in the multi handle (and you
  48. really should if you are working event-based with
  49. \fIcurl_multi_socket_action(3)\fP and friends), that callback will be called
  50. from within this function to ask for an updated timer so that your main event
  51. loop will get the activity on this handle to get started.
  52. The easy handle will remain added to the multi handle until you remove it
  53. again with \fIcurl_multi_remove_handle(3)\fP - even when a transfer with that
  54. specific easy handle is completed.
  55. You should remove the easy handle from the multi stack before you terminate
  56. first the easy handle and then the multi handle:
  57. 1 - \fIcurl_multi_remove_handle(3)\fP
  58. 2 - \fIcurl_easy_cleanup(3)\fP
  59. 3 - \fIcurl_multi_cleanup(3)\fP
  60. .SH EXAMPLE
  61. .nf
  62. /* init a multi stack */
  63. multi_handle = curl_multi_init();
  64. /* add individual transfers */
  65. curl_multi_add_handle(multi_handle, http_handle);
  66. curl_multi_add_handle(multi_handle, http_handle2);
  67. .fi
  68. .SH AVAILABILITY
  69. Added in 7.9.6
  70. .SH RETURN VALUE
  71. CURLMcode type, general libcurl multi interface error code.
  72. .SH "SEE ALSO"
  73. .BR curl_multi_cleanup "(3)," curl_multi_init "(3), "
  74. .BR curl_multi_setopt "(3), " curl_multi_socket_action "(3) "