[Libwebsockets] lws_callback_on_writable

Pranjali Chumbhale pranjalic at safeai.ai
Fri Mar 13 23:58:10 CET 2020


Hello Andy,

Do you know what is the data size that a libwebsocket can send in one go,
Like if I do a lws_write on a client side, It will not block the sending.
It makes the websocket client writable as soon as that data is sent.

Like I can put a limit on the amount of data allowed to be sent at a time.

Regards,
Pranjali


On Fri, Mar 13, 2020 at 11:49 AM <andy at warmcat.com> wrote:

>
>
> On March 13, 2020 6:28:14 PM UTC, Pranjali Chumbhale <pranjalic at safeai.ai>
> wrote:
> >Hello Team,
> >
> >Is it possible to call lws_callback_on_writable with the data to be
> >written?
>
> No... lws' concept is only produce data "just in time" and don't pretend
> the system has endless heap.  "Just in time" means when the networking
> stack indicates it can take more data for that particular connection, we
> should produce it and send it.
>
> When you realized you want to send something and when you actually can
> send something are two different things that may not have much
> relationship... normally it'll take more in ms, but if your phone switches
> cells or you go in a tunnel or drops into the sea it may not take more data
> for seconds or minutes.  So they're treated as two different things.
>
> If you need to make it look like one thing you can use a side buffer or
> lws_buflist to hold your data for when the socket does signal its
> writeble.  But that disconnects that data production from being regulated
> by the connection... eg if you had 10MB or 100MB or whatevetto send it will
> lead to all 10MB or whatever going on the heap if the connection is slow.
> This doesn't scale or work on small devices whereas the lws way does.
>
> -Andy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200313/f1926ab9/attachment.htm>


More information about the Libwebsockets mailing list