Hi,
I have doubt when we use curl, for example, two independent functions one from the other, in each of the functions I must use curl_global_init, and another doubt, in some examples I have seen that at the end of the function they use curl_easy_reset( curl ), but in many other examples I see that this call is not used, what is the difference between using it or not, what is recommended, it depends on some other "special" call, what is the difference?.
I appreciate your help.
Regards,
Javier
about curl functions curl_global_init / curl_easy_reset
Moderator: Rathinagiri
- danielmaximiliano
- Posts: 2763
- Joined: Fri Apr 09, 2010 4:53 pm
- DBs Used: DBF
- Location: Argentina
- Contact:
Re: about curl functions curl_global_init / curl_easy_reset
Hola Javier :
te recomiendo leer la API Curl
https://curl.se/libcurl/c/curl_easy_reset.html
https://curl.se/libcurl/c/curl_global_init.html
te recomiendo leer la API Curl
https://curl.se/libcurl/c/curl_easy_reset.html
https://curl.se/libcurl/c/curl_global_init.html
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace
- vagblad
- Posts: 174
- Joined: Tue Jun 18, 2013 12:18 pm
- DBs Used: MySQL,DBF
- Location: Thessaloniki, Greece
Re: about curl functions curl_global_init / curl_easy_reset
Hi Javier,
curl_global_init() must be called at least once in your program, to setup the environment for the curl library to be used.
curl_easy_init() returns a handle number which you use whenever you call another curl function in order to identify for which specific curl handle you want. You can have multiple curl_easy_init() in your program for different procedures. For example:
or you can call multiple curl_easy_ini() and run each handle in a different thread. just be careful to call the curl_global_init() in the main thread because its not a thread safe function.
curl_easy_reset(CURL Handle) resets all the options(curl_easy_opt) for the specific handle to their default values.
For example in the above code:
you can call curl_easy_reset() to reset the options for a specific handle and then re-setup another set of options for it while maintaining the current connection status, cache etc.
curl_global_init() must be called at least once in your program, to setup the environment for the curl library to be used.
curl_easy_init() returns a handle number which you use whenever you call another curl function in order to identify for which specific curl handle you want. You can have multiple curl_easy_init() in your program for different procedures. For example:
Code: Select all
nCurlHandle_1 := curl_easy_init()
curl_easy_setopt( nCurlHandle_1, HB_CURLOPT_HTTPPOST, .T. ) //Setup this handle only for POST method so you dont have to change the curl_options for it everytime.
nCurlHandle_2 := curl_easy_init()
curl_easy_setopt( nCurlHandle_2, HB_CURLOPT_HTTPGET, .T. ) //Setup this handle only for GET method so you dont have to change the curl_options for it everytime.
curl_easy_reset(CURL Handle) resets all the options(curl_easy_opt) for the specific handle to their default values.
For example in the above code:
Code: Select all
curl_easy_reset(nCurlHandle_1) //this will reset all the setup options for the nCurlHandle_1. so the curl_easy_setopt( nCurlHandle_1, HB_CURLOPT_HTTPPOST, .T. ) is no longer valid.
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
Email: vagblad@gmail.com, Skype: vagblad