#include #include #include #define LOOPS 3 static size_t cb(char *d, size_t n, size_t l, void *p) { /* take care of the data here, ignored in this example */ (void)d; (void)p; return n*l; } int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { int i; curl_easy_setopt(curl, CURLOPT_URL, "https://1.1.1.1/"); curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_3); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3L); for(i=0; i < LOOPS; i++) { int w; /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); /* Check for errors */ if(res) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); break; } printf("Wait 110 seconds\n"); for(w=110; w; w--) { sleep(1); fprintf(stderr, "%d \r", w); } } /* always cleanup */ curl_easy_cleanup(curl); } return 0; }