curl-library
Re: easy_setopts fail, resulting in a crash during easy_perform
Date: Mon, 01 Aug 2005 11:16:01 -0700
Your first assumption is wrong:
CURLE_OK (zero) means that the option was set properly, non-zero means 
an error occurred as <curl/curl.h> defines. See the libcurl-errors(3) 
man page for the full list with descriptions.
RTM: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#RETURN
I didn't see anything wrong with the code, but try removing the 
CURLOPT_VERBOSE.
Jason
Daniel Szczuka wrote:
> The following code is just a simple program I made to allow me to get 
> the  data from www.google.com yet once I execute it, all of the 
> setopt's return  0, which I'm assuming means they failed, and when I 
> don't have the "if(res  != 0)" then the easy_perform call crashes. I'm 
> fairly sure that I built  everything correctly and I have it set to 
> use the dll's since -lcurl for  the static libraries wasn't working. 
> I'm still new to this whole thing so  I'm hoping that I just did 
> something wrong, but with a program this  simplified, I know it's not 
> my code; I just can't see why the setopts  aren't working.
>
> int main() {
>     CURLcode res;
>     curl_global_init(CURL_GLOBAL_ALL);
>     CURL *curl = curl_easy_init();
>     if(curl)
>     {
>         res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, 
> write_output);
>         cout << endl << "setopt for CURLOPT_WRITEFUNCTION " << res << 
> endl;
>         cout << endl << "setopt for CURLOPT_VERBOSE " <<  
> curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) << endl;
>
>         curl_easy_setopt(curl, CURLOPT_URL, "www.google.com");
>         cout << endl << "setopt for CURLOPT_URL " << res << endl;
>         if(res != 0)
>         {
>             try {
>                 CURLcode success = curl_easy_perform(curl);
>                 cout << endl << endl << "CURLCode code " << success 
> <<  endl;
>             }
>             catch(char * str)
>             {
>                 cout << endl << endl << "Caught exception " << str << 
> endl;
>             }
>         }
>         system("Pause");
>     }
> }
>
Received on 2005-08-01