From 62d560b67de3a922bc26ef5c0c2a72a9a09e7905 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 7 Apr 2013 00:09:07 +0200 Subject: [PATCH] Reconnect when the input goes away. --- input.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/input.cpp b/input.cpp index f9f879b..fd71d40 100644 --- a/input.cpp +++ b/input.cpp @@ -61,10 +61,15 @@ void *Input::do_work_thunk(void *arg) void Input::do_work() { CURL *curl = curl_easy_init(); - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Input::curl_callback_thunk); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, this); - curl_easy_perform(curl); + + for ( ;; ) { + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Input::curl_callback_thunk); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, this); + curl_easy_perform(curl); + printf("Transfer ended, waiting 0.2 seconds and restarting...\n"); + usleep(200000); + } } size_t Input::curl_callback_thunk(char *ptr, size_t size, size_t nmemb, void *userdata) -- 2.39.2