I’m trying to compare arrived data in TCP-Client with a QString. But I think, it’s a wring format for comparison. My TCP client is written in Qt and TCP server in C#. Here is example code of Qt my read-function:
void MyClient::slotReadyRead()
{
QString okStr = "OK!";
ui->textEdit->append(okStr);
ui->textEdit->append("Reading...");
QString str = socket->readAll();
ui->textEdit->append(str);
if(str == okStr)
ui->textEdit->append("OK! is true");
else
ui->textEdit->append("OK! is false");
}
And here is C#-server code for writing commands “OK!”:
private void WriteOutput(Commands cmd)
{
if (NS == null)
return;
string str = Enum.GetName(typeof(Commands), cmd);
StreamWriter writer = new StreamWriter(NS);
writer.WriteLine(str + "!");
writer.Flush();
}
In this case cmd would be „OK“.In Qt-TCP Client I get following messages: OK! Reading... OK!
OK! is false But I would like to have a OK! is true :). Which data-format should I choose?