curl-library
Re: requirement to detect proxy connection failure.
Date: Mon, 25 May 2009 19:06:53 +0530
Sir,
here is my code,
CURLcode result;
if(m_pcurl)
{
curl_easy_setopt(m_pcurl, CURLOPT_URL,m_ServerAddress);
curl_easy_setopt(m_pcurl, CURLOPT_PORT, m_ServerPort);
curl_easy_setopt(m_pcurl, CURLOPT_CONNECT_ONLY, 1);
// call back method of curl that read actual Error Message recvied on
socket.
curl_easy_setopt(m_pcurl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(m_pcurl, CURLOPT_ERRORBUFFER, errorBuffer);
if(m_IsProxyEnabled)
{
curl_easy_setopt(m_pcurl, CURLOPT_PROXY, m_ProxyAddress);
curl_easy_setopt(m_pcurl, CURLOPT_PROXYPORT , m_ProxyPort);
long lProxyType = fnCURL_PROXYTYPE(m_proxytype);
curl_easy_setopt(m_pcurl, CURLOPT_PROXYTYPE ,lProxyType);
curl_easy_setopt(m_pcurl, CURLOPT_HTTPPROXYTUNNEL, TRUE);
long lAuthType = fnCURL_AuthenticationType(m_AuthType);
curl_easy_setopt(m_pcurl, CURLOPT_PROXYAUTH ,lAuthType );
if(lAuthType!=CURLAUTH_NONE)
{
curl_easy_setopt(m_pcurl, CURLOPT_PROXYUSERNAME,m_Username);
if(strlen((char*)m_Username)>0)
{
curl_easy_setopt(m_pcurl, CURLOPT_PROXYPASSWORD ,m_Password);
}
}
}
result = curl_easy_perform(m_pcurl);
if (result == CURLE_OK)
{
result = curl_easy_getinfo(m_pcurl, CURLINFO_LASTSOCKET, Socket);
}
return result;
}
else
{
return CURLE_FAILED_INIT;// CURL Initialize error
}
*I need to detect only proxy connection failure for taking some action based
on that.*
Regards,
chandrakant
On 5/25/09, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> On Mon, 25 May 2009, chandrakant gupta wrote:
>
> I have a problem that i am not able to differentiate whether connection to
>> proxy has failed or to the actaul server. In both case it sometinme return
>> error code 07 (CURLE_COULDNT_CONNECT ). how do i differenctiate please help
>> me out. i have a requirement to detect proxy connection failure.
>>
>
> I guess it depends. You didn't really give us any details, so let me say
> this:
>
> $ grep CURLE_COULDNT_CONNECT lib/*.c | wc -l
> 79
>
> --
>
> / daniel.haxx.se
>
Received on 2009-05-25