curl-library
CURLE_COULDNT_RESOLVE_HOST using libcurl easy interface on Linux
Date: Tue, 18 Dec 2012 19:13:34 -0500
Hello,
I am using the libcurl easy interface on Windows and Linux to retrieve files using HTTP.
The code below appears to work fine on Windows, I get the files I need.
On Linux I am getting CURLE_COULDNT_RESOLVE_HOST. Using curl from the
command line I can get the files in Linux and Windows, I can ping google.com, etc. from the
command line in Linux and Windows. I program mostly in Windows and I am a novice in Linux.
I know the Linux version of curl is old but it works and it runs on a machine that I can't update.
Does any part of curl or libcurl need to be installed on Linux or if I just link my program to libcurl,
as I do now, is it all self-contained in the executable like in Windows? I am working on compiling
a newer libcurl but that is slow going for me.
Thanks for any help,
Dave
Windows:
curl version : 7.23.1 (from curl -V) works
libcurl version: 7.19.6 (from curlver.h) works
Linux:
curl version : 7.10.6 (from curl -V) works
libcurl version: 7.19.6 (from curlver.h) fails
// Init
curl_global_init(CURL_GLOBAL_ALL);
// Initialize the curl easy interface
curl = curl_easy_init();
if (curl) {
// The resource to GET
curl_easy_setopt(curl, CURLOPT_URL, get_url);
strcpy(httphdr, tempname);
strcat(httphdr, ".txt");
mktmp (httphdr); // Generate a unique temp filename
hdr = fopen(httphdr, "w");
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, hdr);
if (local_filename) {
// The file it will be copied to locally
curl_easy_setopt(curl, CURLOPT_WRITEDATA, getfile);
}
else {
/* send all data to this function */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
/* we pass our 'jsonbuf' struct to the callback function */
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&jsonbuf);
}
sprintf (userpass, "%s:%s", id, pw);
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
// Skip the check
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
res = curl_easy_perform(curl);
fclose(hdr);
// Cleanup the easy interface
curl_easy_cleanup(curl);
}
// close the local file
if (local_filename && getfile) {
fclose(getfile);
}
// Cleanup curl
curl_global_cleanup();
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-12-19