cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Need urgent help for HTTPS

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 24 Nov 2010 08:28:34 -0800

On Wed, Nov 24, 2010 at 11:01:56AM -0500, amit paliwal wrote:
> Step 3 and 4 can be achieved if we use server -sent events. These facilitates
> the server to send messages asynchronously. Now my question is how can I
> achieve it using libcurl, or can I achieve it or not. can it be done by
> registering callbacks for header, read and write functions or do i just need to
> use CONNECT_ONLY option and then do everythign manually by myself?
>
> Can I do curl_easy_perform() multiple times, whenever I need to do something.
> Can I do something like, when I have some data to send to server, I can pass my
> function as callback to read function and then do curl_easy_perfom()?

curl_easy_perfom() will do an entire HTTP transaction, which as Michael points
out, you're not doing once the server starts sending unsolicited data. I
don't see why you shouldn't be able to do curl_easy_perfom() to do the
HTTP stuff first, then switch to curl_easy_recv() to get the unsolicited
data. You'll have to make sure the server sends a Connection: Keep-Alive header
(or otherwise specifies a persistent connection) during the HTTP phase so
libcurl doesn't tear down the socket. You might also end up with a race
condition if the server-sent asynchronous data is sent in the same TCP
frame as the end of the HTTP transaction (e.g. because of Nagle's
algorithm) if libcurl doesn't return buffered data following the previous
HTTP response in curl_easy_recv() (I think it does this, so you're probably
OK).

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-11-24