curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

RE: About a websockets write callback

From: Dmitry Karpov via curl-library <>
Date: Tue, 21 Jun 2022 20:06:23 +0000

Yes, I agree that having something working for WS will be a good step forward regardless the approach.
And you have enough food for thinking. 😊

I just was trying to point out that WebSocket is a protocol above the HTTP transport layer, and it seems logical to me to separate data callbacks for high-level protocols (which require protocol context in order to understand the data) from "raw" layer 0 transport protocols, even though it is definitely possible to put everything into a single CURLOPT_WRITEFUNCTION callback paying some efficiency or easiness price.

Dmitry Karpov

-----Original Message-----
From: Daniel Stenberg <>
Sent: Tuesday, June 21, 2022 10:11 AM
To: Dmitry Karpov via curl-library <>
Cc: Dmitry Karpov <>
Subject: RE: About a websockets write callback

On Mon, 20 Jun 2022, Dmitry Karpov via curl-library wrote:

> Yes, it would be nice to have just one callback for all WS modes (RAW,
> FRAME, MESSAGE) but using CURLOPT_WRITEFUNCTION callback for that
> purpose doesn't seem like an optimal solution to me because of the
> problems related to passing curl handle to it and making a function
> call to get WS context metadata.

Right, we have to pick one of the two ways where neither is optimal.

I still think I'm going to try with a single CURLOPT_WRITEFUNCTION callback to start with and a "curl_ws_meta()" function that can be used from within that callback to get additional data about the frame - when used in frame mode.

I think getting something working that we can try with is a good thing and then if this turns out feeling too awkward and special, we can switch it around and do a separate callback option instead.


  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
Received on 2022-06-21