cURL / Mailing Lists / curl-library / Single Mail


Re: Libcurl : IP blacklisting

From: Daniel Stenberg <>
Date: Tue, 9 Jun 2015 00:00:55 +0200 (CEST)

On Mon, 8 Jun 2015, BALASAHEB SALUNKE wrote:

> However if I blocked the request and returns "CURL_SOCKET_BAD", it results
> into Connection timeout error i.e. 28.

This seems like a bug. It should really return CURLE_COULDNT_CONNECT (7) or
something like that. I'm looking into a fix for that.

> Is there any way handle this, so that we can return specific return code
> from libcurl that shows request was blcoked.

No you cannot change what libcurl will return there. But since you pass in a
custom pointer to your callback, you can for example pass in a variable that
tell your parent function what the reason for the failure truly was.

Something like this psuedo code approach:

int socketfunc(..., void *userp)
   int *value = (int *)userp;


reason = 0;
curl_easy_setopt(easy, CURLOPT_OPENSOCKETDATA, &reason);

ret = curl_easy_perform();

if (ret) {
   if(reason == I_THINK_THE_USER_IS_SILLY) {
     /* my callback thinks the user is silly */


List admin:
Received on 2015-06-09