qt 网络编程参考资料

Previous Page c++ gui programming with qt4里面Next PageChapter 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,但是需要注意的是,需要必须确保收到足够的数据才能读取。

猜你喜欢

转载自www.cnblogs.com/cute/p/12395501.html