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
其他文章
Linux条件变量pthread_condition细节(为何先加锁,pthread_cond_wait为何先解锁,返回时又加锁)
原文链接: https://www.cnblogs.com/cute/p/12395501.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;
也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/333072
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!