curl_multi_add_handle.3 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 the \fIeasy handle\fP to the \fImulti_handle\fP.
  34. While an easy handle is added to a multi stack, you cannot and you must not
  35. use \fIcurl_easy_perform(3)\fP on that handle. After having removed the easy
  36. handle from the multi stack again, it is perfectly fine to use it with the
  37. easy interface again.
  38. If the easy handle is not set to use a shared (\fICURLOPT_SHARE(3)\fP) cache,
  39. it is made to use a DNS cache that is shared between all easy handles within
  40. the multi handle when \fIcurl_multi_add_handle(3)\fP is called.
  41. When an easy interface is added to a multi handle, it is set to use a shared
  42. connection cache owned by the multi handle. Removing and adding new easy
  43. handles does not affect the pool of connections or the ability to do
  44. connection reuse.
  45. If you have \fICURLMOPT_TIMERFUNCTION(3)\fP set in the multi handle (as you
  46. should if you are working event-based with \fIcurl_multi_socket_action(3)\fP
  47. and friends), that callback is called from within this function to ask for an
  48. updated timer so that your main event loop gets the activity on this handle to
  49. get started.
  50. The easy handle remains added to the multi handle until you remove it again
  51. with \fIcurl_multi_remove_handle(3)\fP - even when a transfer with that
  52. specific easy handle is completed.
  53. You should remove the easy handle from the multi stack before you terminate
  54. first the easy handle and then the multi handle:
  55. 1 - \fIcurl_multi_remove_handle(3)\fP
  56. 2 - \fIcurl_easy_cleanup(3)\fP
  57. 3 - \fIcurl_multi_cleanup(3)\fP
  58. .SH EXAMPLE
  59. .nf
  60. /* init a multi stack */
  61. multi_handle = curl_multi_init();
  62. /* add individual transfers */
  63. curl_multi_add_handle(multi_handle, http_handle);
  64. curl_multi_add_handle(multi_handle, http_handle2);
  65. .fi
  66. .SH AVAILABILITY
  67. Added in 7.9.6
  68. .SH RETURN VALUE
  69. CURLMcode type, general libcurl multi interface error code.
  70. .SH "SEE ALSO"
  71. .BR curl_multi_cleanup "(3)," curl_multi_init "(3), "
  72. .BR curl_multi_setopt "(3), " curl_multi_socket_action "(3) "