我正在 Qt 中构建一个 telnet 服务器应用程序,当我从 linux telnet 客户端连接时,输出看起来很棒。例如,向我的控制台发送 "A" << endl << "B" << endl << "C" 如下所示:
A
B
C
现在,当我从 Windows telnet 客户端连接时,我看到
A
B
C
显然 Qt 的 endl 只发送 '\n'。有一个简单的解决方案吗?如果我用“\r\n”替换endl,我现在会搞乱linux客户端吗?我也必须强制冲洗吗?
这是我用来发送到我的 telnet 客户端的实际代码:
QString block;
QTextStream out(&block, QIODevice::WriteOnly);
out << "Valid commands are: " << endl
<< " help Print this list" << endl
<< " version Print this version" << endl
<< " clientcount Show the number of active telnet clients" << endl
<< " logrotate Rotate the event log file" << endl
<< " shutdown Initiate shutdown secast" << endl
<< " quit Disconnect your telnet session" << endl
<< " stop Shutdown secast" << endl;
tcpSocketPtr->write(block.toUtf8());