cURL / Mailing Lists / curl-library / Single Mail


not getting error details on connection failure

From: Keith Trummel <>
Date: Thu, 13 Mar 2014 21:20:00 +0000

I am using version 7.34.0 of libcurl on Linux. I am using the easy interface and for the most part things are working well.

However, recently I was running a stress test that purposefully uses a lot of HTTP connections and my test was failing with connection failures (CURLE_COULDNT_CONNECT). Despite the fact that I had set up an error buffer (curl_easy_setopt with an option of CURLOPT_ERRORBUFFER) I got no details in the error buffer giving the reason for the failure. I was able to determine the reason that I was failing was that the server I was talking to did not support keep alive and with all of the sockets being created most of them were in TIME_WAIT state and I simply ran out of sockets and it could no longer create a new socket. However, I still didn't understand why I wasn't getting that information back from libcurl. So I investigated some more and found that the problem is in the function singleipconnect in connect.c. When it runs out of sockets I get an EADDRNOTAVAIL error when attempting to connect. In the switch statement in the function that gets handled in the default case and it doesn't bother to put any error information in the error buffer. So the net result is that I end up with no details why it couldn't establish the connection.

Now I was able to work around this by doing the following. If I get an error and it is CURLE_COULDNT_CONNECT and the error buffer is empty, then I make a call to curl_easy_getinfo to get the OS error number. This seems to work, but it seems like a hack. Shouldn't I automatically get this information in the error buffer that I have set up?

Keith Trummel

List admin:
Received on 2014-03-13