c++ gui programming with qt4里面Chapter 15里面的
Writing TCP Client–Server Applications
主要介绍了:
建立在tcp上层的通讯,有两种:
1、以文本行格式的协议,用换行符分割
2、二进制区块协议,每个块前面有一个size,后面跟着数据
QTcpSocket is indirectly derived from QIODevice (through QAbstractSocket), so it can be read from and written to using a QDataStream or a QTextStream. One notable difference when reading data from a network compared with reading from a file is that we must make sure that we have received enough data from the peer before we use the >> operator. Failing to do so may result in undefined behavior.
可以用QDataStream or a QTextStream,但是需要注意的是,需要必须确保收到足够的数据才能读取。
Mastering Qt5 里面的
Keeping Your Sanity with Multithreading
也给了一些参考意见。
Qt文档里面:
Multithreading Technologies in Qt
介绍了各种多线程技术,及怎么选择
Blocking Fortune Client Example
在线程里面阻塞操作tcpsocket
其他文章