curl-library
Re: Serverside Streaming connection using libcurl
Date: Thu, 13 Dec 2018 11:02:53 -0300
Hi Prashant,
I have a small HTTP(s) server library that allows to send large data via
streaming, one of its functions is:
/**
* Sends a stream to the client.
* \param[in] res Response handle.
* \param[in] size Size of the stream.
* \param[in] block_size Preferred block size for stream loading.
* \param[in] read_cb Callback to read data from stream handle.
* \param[in] handle Stream handle.
* \param[in] free_cb Callback to free the stream handle.
* \param[in] status HTTP status code.
* \retval 0 - Success.
* \retval EINVAL - Invalid argument.
* \retval EALREADY - Operation already in progress.
* \note Use `size = 0` if the stream size is unknown.
* \warning It exits the application if called when no memory space is
available.
*/
SG_EXTERN int sg_httpres_sendstream(struct sg_httpres *res, uint64_t size,
size_t block_size, sg_read_cb read_cb,
void *handle, sg_free_cb free_cb,
unsigned int status);
But it seems you are looking for something under "Connection: Upgrade",
like websocket. If so, take a look at the following library:
https://www.gnu.org/software/libmicrohttpd
This feature was announced here:
https://lists.gnu.org/archive/html/libmicrohttpd/2016-09/msg00002.html
Both libraries uses libcURL in their examples.
Cheers
On Thu, Dec 13, 2018 at 10:35 AM Prashant Shubham via curl-library <
curl-library_at_cool.haxx.se> wrote:
> Hi All,
>
> I want to create a streaming connection from client to server using
> libcurl. The client will once connect to server and keep listening for
> responses from the server. Stream teardown can happen when client
> requests.
>
> Example:
>
> 1. Connect to server
> 2. Keep listening for responses to server. Something like while(streamOK){
> //execute function when response arrives
> }
> 3. Teardown connection when CloseStream() invoked.
> I have gone through libcurl but couldn't find a clear implementation
> of streaming connection except rtsp one.
>
> Server will send response/data whenever server is available with the
> data. http2 supports streaming I guess there must be some libcurl apis
> which I can use to implement this functionality. Can you please guide?
>
> All your responses are appreciated in advance.
>
> Regards.
> -------------------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html
-- Silvio Clécio
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-12-13