Hi, I am running a test application to periodically download a file from the server. Here I am creating an curl easy handle at once and using the same for all the future downloads. If I set CURLOPT_DNS_CACHE_TIMEOUT to 2 sec, I expect the application to contact the DNS server and resolve the name every 2 seconds. But I see that DNS requests are sent only once for the first time and never thereafter.
Curl version info: curl-7.72.0. c-ares is not used for test. (Even when the c-ares is used, result is the same) operating system: CentOS - 7 I check the DNS requests using tcpdump: tcpdump -i interface port 53 Could someone explain if I am missing any thing? Below is my code: #include "curl.h" #include <unistd.h> #include <stdio.h> static size_t cb(void *data, size_t size, size_t nmemb, void *userp) { printf("Got data :%u\n",size); size_t realsize = size * nmemb; return realsize; } static void download(CURL* curl,int i) { if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT,2); curl_easy_setopt(curl, CURLOPT_URL, "google.com"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)0); // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); if (res== CURLE_OK) { printf("(%u) Curl get success\n",i); } else { printf("(%u) Curl get failed\n",i); } } printf("_______________________\n"); } static void get(CURL* curl, int loop, int pause) { int i; for(i=0; i<loop; i++) { download(curl,i); sleep(pause); } } int main() { curl_global_init(CURL_GLOBAL_DEFAULT); CURL *curl = curl_easy_init(); get(curl, 100, 1); curl_easy_cleanup(curl); } Thanks, Narasimha
------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html