[Libwebsockets] 回复: How to receive message bigger than 4096 bytes on server side?

Andy Green andy at warmcat.com
Thu Nov 5 04:17:54 CET 2015



On 5 November 2015 10:18:48 GMT+08:00, Nemo <377307289 at qq.com> wrote:
>Thank you andy, I agree what you said. And, in libwebsockets, is there
>special callback or event to tell user where is the end of one message?
>
int libwebsocket_is_final_fragment(struct libwebsocket *wsi);

-Andy
>
>
>------------------ 原始邮件 ------------------
>发件人: "Andy Green";<andy at warmcat.com>;
>发送时间: 2015年11月5日(星期四) 上午9:44
>收件人: "Nemo"<377307289 at qq.com>;
>"libwebsockets"<libwebsockets at ml.libwebsockets.org>; 
>
>主题: Re: [Libwebsockets] How to receive message bigger than 4096 bytes
>on	server side?
>
>
>
>
>
>On 5 November 2015 09:25:22 GMT+08:00, Nemo <377307289 at qq.com> wrote:
>>I have create a websocket server with libwebsockets library, and the
>>protocol list is like this:
>>/* List of supported protocols and callbacks. */ static struct
>>libwebsocket_protocols protocols[] = {     {
>"plain-websocket-protocol"
>>/* Custom name. */,       callback_websocket,       sizeof(struct
>>websocket_client_real),       0 },     { NULL, NULL, 0, 0 } /*
>>Terminator. */ }; 
>>
>>
>>
>>When I use "html + javascript + chrumium browser" as client to send
>>websocket message bigger than 4096 bytes, the websocket server will
>>receive the LWS_CALLBACK_RECEIVE callback more than one time, one
>>message is splited to two or more, and the max receive size is 4096.
>>
>>How can I receive unlimited size websocket message on server side?
>
>If I understand it you are receiving whatever message you sent.  It's
>just notifying you as soon as each chunk arrived.
>
>In the browser, in Javascript, it delays notifying you about the
>message until the whole thing came.  But if you think about it, then
>you can't get a message bigger than your available memory, for example
>a long streaming video.
>
>If that's what you want, you need to reassemble the chunks as they get
>notified into a final buffer yourself.  But it's way more flexible to
>'get it as it comes'.
>
>-Andy
>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Libwebsockets mailing list
>>Libwebsockets at ml.libwebsockets.org
>>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list