Вопрос

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

Certain subclasses of QIODevice, such as QTcpSocket and QProcess, are asynchronous.

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.

But if you call write from 2 unsynchronized threads, the result is undefined.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top