Trouble with QIODevice/QAbstractSocket
-
Hi,
I have to manage a TCP communication between two hosts (P2P connection). But I have some misunderstandings with the API of QIODevice and QAbstractSocket to wait, and be sure that the whole data have been transferred. My problem comes from the fact that QIODevice::write(const QByteArray&) "returns the number of bytes actually written". But in the same time, we have the function QAbstractDevice::waitForBytesWritten() and QIODevice::bytesToWrite().So, my questions are:
-
When I send a small amount of data should I call waitForBytesWritten? Or should I only check the return value of write()?
-
When I send a large amount of data should I iterate on waitForByteWritten until bytesToWrite() return 0? And them do not take care of the return value of write().
-
-
Hi,
From the looks of it, I would say that the transaction is what you are looking for.