# curl_easy_init

Definition: | include builtins\libcurl.e atom curl = curl_easy_init()
Description: | Start a libcurl easy session. This function must be the first function to call, and it returns a CURL easy handle that you must use as input to other functions in the easy interface. This call MUST have a corresponding call to curl_easy_cleanup when the operation is complete. Returns a session handle.
pwa/p2js: | Not supported.
Comments: | If you did not already call curl_global_init, curl_easy_init does it automatically. This may be lethal in multi-threaded cases, since curl_global_init is not thread-safe, and it may result in resource problems because there is no corresponding cleanup. You are strongly advised to not allow this automatic behaviour, by calling curl_global_init yourself properly. A fatal error occurs if something goes wrong. Legacy code may check for NULL, but that is no longer necessary and the equivalent processing should instead be performed via exception handling, if at all - in general Phix takes the perhaps rather stern view that a brutal crash both gives clues and forces a fix, whereas quietly ignoring errors (certainly as opposed to handling them properly) can only lead to frustration, irritation, and annoyance.
Example: | Copy
    include builtins\libcurl.e

    curl_global_init()
    atom curl = curl_easy_init()
    curl_easy_setopt(curl, CURLOPT_URL, "http://example.com")
    atom res = curl_easy_perform(curl)
    curl_easy_cleanup(curl)
    curl_global_cleanup()
See Also: | curl_easy_cleanup, curl_global_init, curl_easy_reset, curl_easy_perform