[Libwebsockets] [libwebsockets] #42: calculates number of actually sent bytes incorrectly in libwebsockets_write

Trac trac at libwebsockets.org
Thu Oct 17 02:11:13 CEST 2013

#42: calculates number of actually sent bytes incorrectly in libwebsockets_write
  Reporter:  andreaspakulat          |      Owner:
      Type:  defect                  |     Status:  new
  Priority:  major                   |  Milestone:
 Component:  libwebsocket test apps  |    Version:
Resolution:                          |   Keywords:

Comment (by agreen):

 At the moment there's no point making this do what you're trying to do.

 The number of bytes "sent" may bear no relationship to what went out on
 the wire because of extension mangling, eg compression, muxing or
 whatever.  You can't write code to estimate the effect of that like you're
 trying to do for header prepending.  You might send a whole 8192 byte
 message successfully but only 6 bytes go on the wire due to compression.

 Further if less bytes are sent than anticipated (something I think should
 no longer be possible) as it stands there is no way to recover from that
 without blocking.

 What the code should do at the moment is detect at the write action if the
 kernel failed to accept it all and close the connection / make a big log
 about it.  If we ever see that happening on user code that takes care
 about the SO_SNDBUF reservation size set in the protocol, then we will
 know we have to do something more about dynamic packet buffering / extra
 states to handle.

 I added a patch for that here


Ticket URL: <http://libwebsockets.org/trac/libwebsockets/ticket/42#comment:2>
libwebsockets <http://libwebsockets.org>
libwebsockets C library

More information about the Libwebsockets mailing list