curl_easy_init.3 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_easy_init 3 "4 March 2002" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_easy_init - Start a libcurl easy session
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURL *curl_easy_init();
  31. .fi
  32. .SH DESCRIPTION
  33. This function allocates and returns a CURL easy handle. Such a handle is used
  34. as input to other functions in the easy interface. This call must have a
  35. corresponding call to \fIcurl_easy_cleanup(3)\fP when the operation is
  36. complete.
  37. The easy handle is used to hold and control a single network transfer. It is
  38. encouraged to reuse easy handles for repeated transfers.
  39. An alternative way to get a new easy handle is to duplicate an already
  40. existing one with \fIcurl_easy_duphandle(3)\fP, which has the upside that it
  41. gets all the options that were set in the source handle set in the new copy as
  42. well.
  43. If you did not already call \fIcurl_global_init(3)\fP before calling this
  44. function, \fIcurl_easy_init(3)\fP does it automatically. This may be lethal in
  45. multi-threaded cases, if \fIcurl_global_init(3)\fP is not thread-safe in your
  46. system, and it may then result in resource problems because there is no
  47. corresponding cleanup.
  48. You are strongly advised to not allow this automatic behavior, by calling
  49. \fIcurl_global_init(3)\fP yourself properly. See the description in
  50. \fBlibcurl\fP(3) of global environment requirements for details of how to use
  51. this function.
  52. .SH EXAMPLE
  53. .nf
  54. CURL *curl = curl_easy_init();
  55. if(curl) {
  56. CURLcode res;
  57. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  58. res = curl_easy_perform(curl);
  59. curl_easy_cleanup(curl);
  60. }
  61. .fi
  62. .SH AVAILABILITY
  63. Always
  64. .SH RETURN VALUE
  65. If this function returns NULL, something went wrong and you cannot use the
  66. other curl functions.
  67. .SH "SEE ALSO"
  68. .BR curl_easy_cleanup "(3), " curl_global_init "(3), " curl_easy_reset "(3), "
  69. .BR curl_easy_perform "(3), " curl_easy_duphandle "(3), "
  70. .BR curl_multi_init "(3), "