curl / Mailing Lists / curl-library / Single Mail

curl-library

Libcurl server-sent events (SSE) write callback notification

From: Chris Dolfin via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 13 Feb 2019 16:41:32 -0500

I am trying to understand how to implement licburl client to process server
sent events

SSE; W3C Recommendation, January 2015

http://www.w3.org/TR/eventsource

Libcurl always call the “write callback” when it receives HTTP response and
stores the data in the structure provided by the user.

In normal request curl_easy_perform(,,) returns and I know that there is
data in my buffer.

The pseudo code for normal libcurl flow

// initialize

Curl_easy_init()

curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);

curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

res = curl_easy_perform(curl);

At this stage I know that there is data in readBuffer.

At this stage the server will send more data and WriteCallback will be
called to write data to readBuffer.

How do I get notification that there is data waiting for me?

I cannot call curl_easy_perform() because I should not send new request.

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-02-14