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); }