Thanks Daniel, Your solution worked very well.
Now, Just figuring out why curl returns Connection timeout error i.e. 28 instead of CURLE_COULDNT_CONNECT(7) after CURLOPT_OPENSOCKETFUNCTION function return "CURL_SOCKET_BAD". Thanks and Regards, Balasaheb Salunke cell : +91 8087699715 / +91 9766162204 On Tue, Jun 9, 2015 at 3:30 AM, Daniel Stenberg <[email protected]> wrote: > 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; > > *value = I_THINK_THE_USER_IS_SILLY; > } > > 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 */ > ... > } > > } > > -- > > / daniel.haxx.se > ------------------------------------------------------------------- > List admin: http://cool.haxx.se/list/listinfo/curl-library > Etiquette: http://curl.haxx.se/mail/etiquette.html
------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
