Hello,

Last year when we brainstormed different takes on a WebSockets idea, we landed on a separate ws callback for writing data, similar to the regular CURLOPT_WRITEFUNCTION. [*]

A separate callback, because it needs to provide some additional data that the plain callback doesn't receive.

Now when I've started working on implementing websockets, I'm having second thoughts on that design but I can't decide on what's a better way. So I'm here to see if someone else can fix this for me! =)

I would like to provide websockets data with the CURLOPT_WRITEFUNCTION callback as well. But how would libcurl provide the additional necessary metadata?

My initial thought was to provide a special websocket function that only can be used from within the callback that would provide the extra information (type of data, opcode, and if the FIN bit is set or not etc). Like maybe
'curl_ws_metadata()'.

This is what makes me hesitate on this idea:

This new function would need to get the easy handle as an argument, so that it can find and return the correct information, but the CURLOPT_WRITEFUNCTION does not pass in the easy handle! So in order to use this function within the callback, it would require that the callback on its own design gets the easy handle passed into it via the CURLOPT_WRITEDATA option in some manner.

Would that be a sensible requirement or would be asking too much of an application?

Or can we come up with a better way?

[*] = https://github.com/curl/curl/wiki/WebSockets

--

 / daniel.haxx.se
 | Commercial curl support up to 24x7 is available!
 | Private help, bug fixes, support, ports, new features
 | https://curl.se/support.html
--
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to