curl_easy_init.3 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. .\" generated by cd2nroff 0.1 from curl_easy_init.md
  2. .TH curl_easy_init 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_easy_init \- create an easy handle
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURL *curl_easy_init();
  9. .fi
  10. .SH DESCRIPTION
  11. This function allocates and returns a CURL easy handle. Such a handle is used
  12. as input to other functions in the easy interface. This call must have a
  13. corresponding call to \fIcurl_easy_cleanup(3)\fP when the operation is complete.
  14. The easy handle is used to hold and control a single network transfer. It is
  15. encouraged to reuse easy handles for repeated transfers.
  16. An alternative way to get a new easy handle is to duplicate an already
  17. existing one with \fIcurl_easy_duphandle(3)\fP, which has the upside that it gets
  18. all the options that were set in the source handle set in the new copy as
  19. well.
  20. If you did not already call \fIcurl_global_init(3)\fP before calling this function,
  21. \fIcurl_easy_init(3)\fP does it automatically. This can be lethal in multi\-threaded
  22. cases for platforms where \fIcurl_global_init(3)\fP is not thread\-safe, and it may
  23. then result in resource problems because there is no corresponding cleanup.
  24. You are strongly advised to not allow this automatic behavior, by calling
  25. \fIcurl_global_init(3)\fP yourself properly. See the description in \fIlibcurl(3)\fP of
  26. global environment requirements for details of how to use this function.
  27. .SH PROTOCOLS
  28. This functionality affects all supported protocols
  29. .SH EXAMPLE
  30. .nf
  31. int main(void)
  32. {
  33. CURL *curl = curl_easy_init();
  34. if(curl) {
  35. CURLcode res;
  36. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  37. res = curl_easy_perform(curl);
  38. curl_easy_cleanup(curl);
  39. }
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.1
  44. .SH RETURN VALUE
  45. If this function returns NULL, something went wrong and you cannot use the
  46. other curl functions.
  47. .SH SEE ALSO
  48. .BR curl_easy_cleanup (3),
  49. .BR curl_easy_duphandle (3),
  50. .BR curl_easy_perform (3),
  51. .BR curl_easy_reset (3),
  52. .BR curl_global_init (3),
  53. .BR curl_multi_init (3)