[Libwebsockets] Please explain what is rx_flow_control , and what is fx flow , and how it is related to binary data

Meir Yanovich meiry242 at gmail.com
Mon Jun 20 10:46:09 CEST 2016


Thanks !

On Mon, Jun 20, 2016 at 11:39 AM, Andy Green <andy at warmcat.com> wrote:

>
>
> On 06/20/2016 04:28 PM, Meir Yanovich wrote:
>
>> Hello
>> i want to add support to my server to able handling binary data from
>> client .
>>
>
> There is no difference between text and binary ws messages for lws, except
> you use LWS_WRITE_BINARY.
>
> i have only 1 example which is test-echo.c .
>> i can see the handling of the incoming binary data using
>> LWS_WRITE_BINARY protocol.
>> i can see there is some kind of "rx" handling in the code :
>>
>
> This is unrelated to binary or not.  There is no requirement to do rx flow
> control just because you want to send a binary ws mesage.
>
> case LWS_CALLBACK_RECEIVE:
>> do_rx:
>> pss->final = lws_is_final_fragment(wsi);
>> pss->binary = lws_frame_is_binary(wsi);
>> lwsl_info("+++ test-echo: RX len %d final %d, pss->len=%d\n",
>>  len, pss->final, (int)pss->len);
>>
>> memcpy(&pss->buf[LWS_PRE], in, len);
>> assert((int)pss->len == -1);
>> pss->len = (unsigned int)len;
>> pss->rx += len;
>>
>> lws_rx_flow_control(wsi, 0);
>> lws_callback_on_writable(wsi);
>> break;
>>
>> how does it all connects ?
>>
>
> Binary ws messages and rx flow control are unrelated.
>
> RX flow control allows the user code to halt processing of incoming RX
> until later.
>
> Often in network programming, the rate you can accept new input is not
> decided by the guy sending it, it's decided by the guy you are sending to.
>
> In the case your onward destination can't accept any more right now, you
> have to create "backpressure" that stops more new input being processed.
>
> This -->
>
> > lws_rx_flow_control(wsi, 0);
> > lws_callback_on_writable(wsi);
>
> is part of stopping new rx coming until the onward recipient accepted some
> data.
>
> Take a look at what the mirror protocol example does about it as well.
>
> also as i side note ,
>> in test-echo.c i can see there is also the client code included i can't
>> understand how i start the client from the same file of the server , (
>> the server is starting great )
>>
>
> Just do something similar to what it does in test-client.c does.  If he's
> not connected, he tries to connect asynchronously every couple of seconds.
>
> It's OK in lws >2.0 to mix server and client connections for ws or http in
> the same context.
>
> -Andy
>
>
> Thanks
>>
>>
>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> http://libwebsockets.org/mailman/listinfo/libwebsockets
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20160620/6be99c61/attachment-0001.html>


More information about the Libwebsockets mailing list