[Libwebsockets] Using libwebsockets as a codec
andy at warmcat.com
Tue Jun 9 16:17:12 CEST 2020
On 6/9/20 3:02 PM, Andy Green wrote:
> On 6/9/20 2:54 PM, Ganesh Murthy wrote:
>> Our application has its own IO layer and is capable of providing
>> libwebsockets with raw byte buffers. Does lws have a pure codec mode
>> which takes in these buffers and produces http events that I can then
>> go on and use? This question was already asked 4 years ago here -
>> The closest I could find to an api that accepts buffers is
>> but I don't have access to file descriptors.
> "Codec" means [en]coder/decoder it might mean something to you but it
> doesn't give me any picture of what you are talking about when you say
> that phrase wrt lws.
> Do you mean perhaps lws "raw" protocol? This just passes payload around
> without applying or removing any framing, eg
Never mind I read the thread you linked...
What I was saying in there about flow control is even more relevant now
lws supports, eg, ws-over-h2.
The general feeling was that the focus was on your backend and the
network stuff should just be a black box that plays well with what you
had... due to things like tx credit management and flow control
generally, the network part needs to have its own event loop that it is
in charge of. Eg the OP mentioned for flow control
> If the write buffer fills up, the read-buffer is disabled till there
is some write space.
that seems to make a lot of assumptions about where the data is going
and relationship between tx situation and rx situation that might be so
in, eg, a proxy, but not be true for anything else.
You can fill and drain these buffers from another thread and just let
lws do whatever it's doing with them asynchronously... I am pretty sure
that can be made to work. Anything else, maybe I am just too dumb to
see the light but it seemed a lot of grinding and clanking noises that
could be expected were getting glossed over.
More information about the Libwebsockets