简体   繁体   English

在QTcpSocket :: write上多次调用?

[英]Multiple calls on QTcpSocket::write?

According to here http://doc-snapshot.qt-project.org/4.8/qiodevice.html 根据这里http://doc-snapshot.qt-project.org/4.8/qiodevice.html

Certain subclasses of QIODevice, such as QTcpSocket and QProcess, are asynchronous. QIODevice的某些子类(例如QTcpSocket和QProcess)是异步的。

For example, the first write call has been made to send a chunk of data. 例如,已进行第一个写调用以发送数据块。 Now before the first write call finishes, a second write call has also been made to send another chunk of data. 现在,在第一个写调用完成之前,还进行了第二个写调用以发送另一个数据块。

What happens now? 现在会发生什么? Does the second call waits for the first call to completely finish before starting to send the chunks? 在开始发送块之前,第二个呼叫是否等待第一个呼叫完全完成?

The data is buffered at least by the system TCP stack, so each call to write "just" appends the new chunk to the unwritten data waiting to be sent. 数据至少由系统TCP堆栈缓冲,因此每次write “ just”调用都会将新块附加到等待发送的未写数据上。

But if you call write from 2 unsynchronized threads, the result is undefined. 但是,如果您从2个未同步的线程调用write ,则结果是不确定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM