1curl_easy_init(3) libcurl Manual curl_easy_init(3)
2
3
4
6 curl_easy_init - Start a libcurl easy session
7
9 #include <curl/curl.h>
10
11 CURL *curl_easy_init( );
12
14 This function must be the first function to call, and it returns a CURL
15 easy handle that you must use as input to other functions in the easy
16 interface. This call MUST have a corresponding call to
17 curl_easy_cleanup(3) when the operation is complete.
18
19 If you did not already call curl_global_init(3), curl_easy_init(3) does
20 it automatically. This may be lethal in multi-threaded cases, since
21 curl_global_init(3) is not thread-safe, and it may result in resource
22 problems because there is no corresponding cleanup.
23
24 You are strongly advised to not allow this automatic behaviour, by
25 calling curl_global_init(3) yourself properly. See the description in
26 libcurl(3) of global environment requirements for details of how to use
27 this function.
28
30 If this function returns NULL, something went wrong and you cannot use
31 the other curl functions.
32
34 CURL *curl = curl_easy_init();
35 if(curl) {
36 CURLcode res;
37 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
38 res = curl_easy_perform(curl);
39 curl_easy_cleanup(curl);
40 }
41
43 curl_easy_cleanup(3), curl_global_init(3), curl_easy_reset(3),
44 curl_easy_perform(3)
45
46
47
48libcurl 7.69.1 February 03, 2016 curl_easy_init(3)