mirror of
https://github.com/modelec/TCPSocketClient.git
synced 2026-01-18 16:37:35 +01:00
add \n to the end of frame
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user