cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: issue with quick reconnect

From: Jogeshwar Karthik Akundi <ajkarthik_at_gmail.com>
Date: Fri, 14 Aug 2009 17:10:18 +0530

Hi Daniel,
Unfortunately at this point I cannot share the source code with all.
But at a very high level it is like this:

curlOps()
{
    //init curl handle
    int sock;
    m_curlHandle = curl_easy_init();
    //set CONNECT_ONLY option on the curl Handle
    curl_easy_setopt(m_curlHandle, CURLOPT_CONNECT_ONLY, 1L);
    //connect to HTTPS server
    //set options for server
    curl_easy_perform(m_curlHandle);
    curl_easy_getinfo(m_curlHandle, CURLINFO_LASTSOCKET, &sock);
    //perform some operations
    //reads and writes basically using curl_easy_recv, curl_easy_send
    //disconnect
    curl_easy_cleanup(m_curlHandle);
}

performAction()
{
    curl_global_init(CURL_GLOBAL_ALL);
    while(some_condition)
    {
        curlOps();
    }
    curl_global_cleanup();
}

The connection establishment (curl_easy_perform) and retrieving raw socket
also work fine always. I have been going through the logs and some more info
I gathered was that:
Initially, after a successful connection, I do a write operation using
curl_easy_send() and then do a curl_easy_recv(). the send operation is also
going fine but I get this error in the receive operation.

Also, If there is a delay between the closing and opening a new connection,
things are working fine, but here in one scenario we issue a rapid restart
of the client. This is causing problems.

I googled for this and found some more info:
*easy_connection() *method in easy.c logs this error (*Failed to get recent
socket*) when the sockfd is -1 and the returned curl code is 1. But here my
connection is going through fine and the initial curl_easy_send() is also
being successful so I am baffled as to what could have gone wrong

Thanks
Karthik

On Fri, Aug 14, 2009 at 4:43 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Fri, 14 Aug 2009, Jogeshwar Karthik Akundi wrote:
>
> The following is the scenario in which curl gives me an error:
>>
>
> You're on the wrong maling list! Switch over to the curl-library list
> instead, where all the libcurl hackers are. This reply is cc'ed there.
>
> 1) I Connect to my server from my client program using the easy api of
>> libcurl (HTTPS, libcurl compiled with openSSL)
>> 2) Close the connection
>> 3) Immediately connect again with a new curl easy handle.
>>
>
> Can you show us a complete (small) source code that repeats this problem?
>
> Issue is that the connection goes through fine but the read operation
>> fails.
>>
>
> On this particular server/URL or on all servers/URLs ?
>
> This works most of the times but sometimes (about one in eight cases) I
>> get an error when I try to read using curl_easy_recv. it returns curlcode =
>> 1 (unsupported protocol).
>>
>
> Uh, there's no call to curl_easy_recv() in your description above!
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
> FAQ: http://curl.haxx.se/docs/faq.html
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-08-14