The code snippet is as follows:
const int BUFFERSIZE = 50*1024;
char lLoadedData[BUFFERSIZE];
memset(lLoadedData, 0, sizeof(lLoadedData));
mstrURL = "http://www.google.com";
CURL* lCurlHandle = curl_easy_init();
if (lCurlHandle)
{
//url
if ((error_code = curl_easy_setopt(lCurlHandle, CURLOPT_URL, mstrURL)) != CURLE_OK)
return;
if((error_code = curl_easy_setopt(lCurlHandle, CURLOPT_WRITEDATA, (void *)lLoadedData)) != CURLE_OK)
return;
error_code = curl_easy_perform(lCurlHandle);
if (error_code == CURLE_OK)
{
...
}
}
The error_code after executing curl_easy_perform() is CURLE_COULDNT_RESOLVE_HOST.
I have changed the DNS server to 8.8.8.8 and 4.4.4.4, but the error_code is still unchanged.
Does anybody know how to fix this problem? Thanks!
Environment: Windows server 2008, VS 2010.
================update===================== Seems the parameter is wrong. should be: if ((error_code = curl_easy_setopt(lCurlHandle, CURLOPT_URL, mstrURL.c_str())) != CURLE_OK)