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: Send data before receiving data using the callback approach for WebSocket requests

From: Dmitry Karpov via curl-library <>
Date: Mon, 19 Jun 2023 22:15:52 +0000

The "open" callback covers a bunch of use cases when WS client needs to send something immediately after opening a WebSocket.
So, when this callback is called, the WebSocket should be opened successfully and fully operational, so it can send WS messages.

Practical use cases depend on WS applications, and their proprietary WS-message based communication protocols.
One example that I know is some WS client app communicating to a remote WS application controlling a web camera.
After opening a WebSocket, it sends some command requesting to send back a camera status.

A good test use case to test this callback is to open a WebSocket on some public "echo" WS server (which "echoes" back a WS message it receives),
send some WS message (text or binary) in the "open" callback and verify that our WS client receives the same message back.

Dmitry Karpov

-----Original Message-----
From: Daniel Stenberg <>
Sent: Sunday, June 18, 2023 2:47 PM
To: Dmitry Karpov via curl-library <>
Cc: Dmitry Karpov <>
Subject: [EXTERNAL] Re: Send data before receiving data using the callback approach for WebSocket requests

On Wed, 7 Jun 2023, Dmitry Karpov via curl-library wrote:

> I think there should be WS_OPEN callback, called when WebSocket has
> been successfully opened, which would allow to send data right after opening.

I'm open for discussing/implementing this. Ideally if someone has a use case that needs this feature that we can work with to make sure it works fine.

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