[Libwebsockets] Handling partial send from libwebsocket_write with binary data

Peter Bergin peter.bergin at tritech.se
Fri Apr 17 13:53:26 CEST 2015


I have an application that send binary data over websocket. When changing platform we got changed behaviour of the sockets and on the new platform we get stuck with a 5kB send size due to bad implementation.

In the LWS_CALLBACK_CLIENT_WRITEABLE callback I call libwebsocket_write with a buffer of size 6181. The function returns that it has send 5792 bytes. In our implementation we missed to take care of the return value and handle the case that the send was truncated.

I can not find how to handle this case properly and need some help.

In LWS_CALLBACK_CLIENT_WRITEABLE call back I have this call

int res = libwebsocket_write (wsi, (unsigned char*)buff+LWS_SEND_BUFFER_PRE_PADDING , instance->mSendDataLen, LWS_WRITE_BINARY);

mSendDataLen = 6144
res will become 5792 when returned.
How shall I proceed in a correct way?

Best regards,

Peter Bergin

peter.bergin at tritech.se
+46 733 35 21 05

+46 31 763 38 00
Nordstadstorget 6
SE-411 05 G?teborg, Sweden

More information about the Libwebsockets mailing list