[Libwebsockets] libwebsocket_write returning less than the specified length
andy at warmcat.com
Sat Jul 5 05:34:58 CEST 2014
On 07/03/2014 02:51 AM, Mike M wrote:
> How are we supposed to deal with partial writes? Did it actually send
> some of the data and next time we get a writeable callback we are
> supposed to send the rest?
Yeah we asked to send the whole thing, but it only sent some of it.
In recent git versions lws attempts to cache the remaininder and send it
> Sometimes, I notice the pipe getting choked even if it has written the
> entire buffer, and sometimes it's choked when it partially writes the
> buffer. Is there any purpose to checking if the pipe is choked?
Yes that it network programming life.
Imagine your peer is on a GPRS connection in a tunnel, you are not going
to be able to send as much as you want on that connection before someone
gets fed up buffering that for you and stops accepting it.
If you send even when the pipe is choked, the whole thread / process is
blocked until there's space in the kernel for more tx data to be buffered.
If you check first if it would choke and mark the connection to be
called back when it is writeable and return to the main service loop,
none of your other connections are delayed by the guy in the tunnel, or
who dropped his phone in a lake etc. As soon as he can accept more,
you'll get a writeable callback for that connection but in the meanwhile
you could serve everyone else.
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets