cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: (Secure) Websockets using libcurl

From: Frank Meier <frank.meier_at_ergon.ch>
Date: Wed, 18 May 2016 11:25:14 +0200

On 17/05/16 17:23, Patrick Rathje wrote:
> Hey,
> I am using libcurl for HTTP(s) already.
> Now I would like to support Secure Websockets as well, but could not really find much information how this is done using libcurl.

Hi Patrick

If you like to get your hands dirty, you could have a look at my
approaches (patches) mentioned in
http://comments.gmane.org/gmane.comp.web.curl.library/45993.

The second patch which enables you to retrieve the the active connection
socket I use productively for some time now.

This approach let libcurl do the HTTP part of the upgrade, and as your
code detects that the WebSocket-Upgrade is accepted by the server (got
101 and correct response headers), you set CURLPAUSE_ALL on the
easyhandle, and then use curl_easy_recv() and curl_easy_send() to
receive/send websocket data on the established connection. You also need
to get the socket of the easyhandle with CURLINFO_ACTIVESOCKET so you
can poll() on it.

cheers, Frank

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-05-18