You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example of the server, you are using malloc to copy the data before using lws_write as in:
...
out = (char )malloc(sizeof(char)(LWS_SEND_BUFFER_PRE_PADDING + len + LWS_SEND_BUFFER_POST_PADDING));
memcpy (out + LWS_SEND_BUFFER_PRE_PADDING, str, len );
n = lws_write(wsi_in, out + LWS_SEND_BUFFER_PRE_PADDING, len, LWS_WRITE_TEXT);
If the buffer is very large, this copy all the data for almost nothing here.
because of that, libwebsocket is very slow. In fact an ajax based solution is twice as fast as websocket.
Is there another way to do this ?
The text was updated successfully, but these errors were encountered:
It looks like you are pasting from an old version of lws-mirror-protocol, that's the only example code that has this structure.
Using malloc per message, or predefining the ringbuffer is completely the decision of the user code. lws-mirror does it with malloc so it can handle any size message. But if you know the message size limit, you can malloc the ringbuffer at init one time instead perfectly well.
But the ringbuffer itself and the memcpy is needed if you will serve many clients with the same data. Because they will consume it - become writable - each at their own speed.
In the example of the server, you are using malloc to copy the data before using lws_write as in:
...
If the buffer is very large, this copy all the data for almost nothing here.
because of that, libwebsocket is very slow. In fact an ajax based solution is twice as fast as websocket.
Is there another way to do this ?
The text was updated successfully, but these errors were encountered: