cURL / Mailing Lists / curl-library / Single Mail


Cannot connect to a http server after a failed attempt for some time

From: Gustavo Henrique <>
Date: Tue, 21 Jan 2014 11:56:36 -0200

I'm using libcurl 7.31.0 to do http requests to a server on a machine
located on local network every 3 seconds. It works fine, but if one
connection attempt fails ("Couldn't connect to server" error), when, for
any reason, the server goes down, when it comes back I still cannot connect
to it for some time (keep receiving "Couldn't connect to server error") .
 After some time (about 1 minute), I'm able to connect to it again.

I don't think it's related to the server configuration, because when
testing via browser, this weird behavior is not seen (I'm able to connect
to the server as soon as it goes up).

The code I'm running is:

int main(void) {
CURL *curl;
CURLcode res;
size_t size;
std::string result;
curl = curl_easy_init();
 curl_easy_setopt(curl, CURLOPT_URL, "");

if (curl) {
res = curl_easy_perform(curl);
 /* Check for errors */
if (res != CURLE_OK) {
printf("ERROR! curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
} else {
printf("\nReceived: ");
    return 0;

Any ideas how to solve it?


List admin:
Received on 2014-01-21