curl-library
easy_setopts fail, resulting in a crash during easy_perform
Date: Mon, 01 Aug 2005 10:51:33 -0700
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