From 76a0f874be3f7617a8740db6f37de996d78beab5 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Thu, 4 Apr 2024 19:07:56 +0200 Subject: [PATCH] add \n to the end of frame --- src/TCPClient.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/TCPClient.cpp b/src/TCPClient.cpp index 92ec7f4..5f4f066 100644 --- a/src/TCPClient.cpp +++ b/src/TCPClient.cpp @@ -22,10 +22,18 @@ TCPClient::TCPClient(const char* serverIP, int port) : running(false) { } void TCPClient::sendMessage(const char* message) const { - send(clientSocket, message, strlen(message), 0); + if (!endWith(message, "\n")) { + std::string messageStr(message); + messageStr += "\n"; + } + + send(clientSocket, messageStr.c_str(), messageStr.size(), 0); } void TCPClient::sendMessage(const std::string& message) const { + if (!endWith(message, "\n")) { + message += "\n"; + } send(clientSocket, message.c_str(), message.size(), 0); }