Skip to content

Commit

Permalink
TcpClient does not send incomplete packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
acburigo authored and mikee47 committed Mar 7, 2024
1 parent d9d97bd commit 1e03c46
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sming/Components/Network/src/Network/TcpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ bool TcpClient::send(const char* data, uint16_t len, bool forceCloseAfterSent)
memoryStream = new MemoryDataStream();
}

if(memoryStream->write(data, len) != len) {
if(!memoryStream->ensureCapacity(memoryStream->getSize() + len)) {
debug_e("TcpClient::send ERROR: Unable to store %d bytes in buffer", len);
return false;
}

memoryStream->write(data, len);

return send(memoryStream, forceCloseAfterSent);
}

Expand Down

0 comments on commit 1e03c46

Please sign in to comment.