Hi! I was experimenting with sending WebSocket requests using libcurl.
Since my codebase already uses the callback approach for HTTP requests and
I was just adding support for WebSocket connections, I thought of
continuing using the same write callback for WebSocket connections too.
However, I was trying to connect with a WebSocket server that expects the
client to send data before responding. So I had a question:

When using the callback approach
<https://everything.curl.dev/libcurl/ws/concept#1.-the-callback-approach>,
is it possible to run curl_ws_send() right after the connection is
established, before the write callback function is executed for the first
time?

It isn't documented but I still tried setting CURLOPT_READFUNCTION to a
valid read callback function but that didn't work, so I guess read
callbacks are not expected to work when doing WebSocket requests. Does this
mean that I would need to use the connect-only approach
<https://everything.curl.dev/libcurl/ws/concept#2.-the-connect-only-approach>
for WebSocket connections?

Even if we find a solution for the callback approach, I was wondering if
any of these approaches <https://everything.curl.dev/libcurl/ws/concept> are
recommended over the other?

Thanks!
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to