[Libwebsockets] Websocket frame size

Mykola Stryebkov mykola.stryebkov at icloud.com
Sat Sep 19 22:43:16 CEST 2020


Thanks, Andy! It’s exactly what I was looking for.

— 
With respect, M.
Public GnuPG key: 0x01731B47DBD56C0F
fpr: 0226 54EE C1FF 8636 36EF  2AC9 BCE9 CFC7 9CF4 6747

> 19 вер. 2020 о 21:33 Andy Green <andy at warmcat.com> написав(ла):
> 
> 
> 
> On 9/19/20 6:38 PM, Mykola Stryebkov wrote:
>> Hi,
>> I’m probably missing something.
>> Is there any way to know the size of received websocket frame?
> 
> You can find how many bytes are left in the current fragment, but that may not be as useful as you are hoping
> 
> https://libwebsockets.org/git/libwebsockets/tree/include/libwebsockets/lws-misc.h#n604-624
> 
> Ws fragments are analogous to tcp frames, they may be refragmented by intermediaries and their size is a function of something unrelated to the payload, the mtu or the buffering arrangements at the sender or an intermediary.
> 
> The message, made up of one or more fragments is the logical unit that's transferred over ws, and its length isn't known beforehand if it comes in multiple fragments, you keep appending fragments until you see one with the FIN bit set.
> 
> You can find out if this RX is the final one with this.
> 
> https://libwebsockets.org/git/libwebsockets/tree/include/libwebsockets/lws-ws-state.h#n40-46
> 
> -Andy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200919/04c2e815/attachment.htm>


More information about the Libwebsockets mailing list