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 committed Feb 29, 2024
1 parent 8939766 commit 79a9e76
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 79a9e76

Please sign in to comment.