From 79a9e767cb9a036d127654e1af8f7dac9b0c8df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Crippa=20B=C3=BArigo?= Date: Thu, 29 Feb 2024 14:31:17 -0300 Subject: [PATCH] TcpClient does not send incomplete packets. --- Sming/Components/Network/src/Network/TcpClient.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sming/Components/Network/src/Network/TcpClient.cpp b/Sming/Components/Network/src/Network/TcpClient.cpp index b0c1e7b45e..56b151352d 100644 --- a/Sming/Components/Network/src/Network/TcpClient.cpp +++ b/Sming/Components/Network/src/Network/TcpClient.cpp @@ -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); }