cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Libcurl comet connection

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 24 Nov 2015 22:32:23 +0100 (CET)

On Tue, 24 Nov 2015, john wrote:

> I want to establish a connection to the host with a HTTP post. This
> connection needs to stay open.

libcurl won't close it without reason so you just have to make sure your
server holds it open. A typical way to accomplish that is to respond with a
chunked response and let each new "message" from the server be another chunk.
And you can implement a "keep-alive" chunk to prevent the connection to have
to be completely idle for a very long time (as NATs and firewalls will then
close it).

> With the things I have tried with Libcurl, the initial connect seems to get
> closed after the initial Post/Response transfer completes.

libcurl only closes it if the server marked the response saying it should be.
Or if you closed the easy handle.

You should probably consider showing us some actual HTTP traffic if you think
libcurl closed something when it shouldn't have done it. Or possibly a piece
of code.

> I’m currently reworking my POC to use curl_multi_socket_action.

You can do this with any of the libcurl APIs, its really mostly a matter of
how you want it to work.

-- 
  / daniel.haxx.se

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