Hello, I'm trying to download files using CURL but it always just shows some weird errors about not being able to resolve hostnames and I wasn't really able to find anything about it
The internet settings on my 3DS are correct and everything
The errors:
The code:
The internet settings on my 3DS are correct and everything
The errors:
Code:
* timeout on name lookup is not supported
* Curl_ipv4_resolve_r failed for [domain]
* Couldn't resolve host '[domain]'
* Closing connection 0
Code:
void http_init() {
curl_global_init(CURL_GLOBAL_ALL);
}
void http_exit() {
curl_global_cleanup();
}
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) {
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
return written;
}
unsigned char http_downloadfile(const char* url, const char* filename) {
std::cout << url << ", " << filename << '\n';
CURL *curl_handle;
CURLcode cres;
FILE *file;
/* init the curl session */
curl_handle = curl_easy_init();
/* set URL to get here */
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
/* Switch on full protocol/debug output while testing */
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
/* disable progress meter, set to 0L to enable it */
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(curl_handle, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl_handle, CURLOPT_STDERR, stdout);
//Open file
file = fopen(filename, "wb");
if(file) {
/* write the page body to this file handle */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, file);
/* get it! */
cres = curl_easy_perform(curl_handle);
/* close the header file */
fclose(file);
} else {
//Unable to open file
std::cout << "Unable to open file in http_downloadfile\n";
return 255;
}
curl_easy_cleanup(curl_handle);
if (cres != CURLE_OK) {
return 128;
}
return 0;
}