Solved Why QTcpSocket::waitForBytesWritten returns immediately
-
When i send data with
QTcpSocket::write
, and after usewaitForBytesWritten
, it returns 1 immediately.
So when i send big arrays (>5 Mb) wireshark shows, that data still sending, butwaitForBytesWritten
returns when data not sent yet.QTcpSocket::bytesToWrite
also return 0 bytes after calling write function. How can i know when data sent fully?P.S. Sorry for my english)
-
Hi @skibon02 ,
When i send data with
QTcpSocket::write
, and after usewaitForBytesWritten
, it returns 1 immediately.
So when i send big arrays (>5 Mb) wireshark shows, that data still sending, butwaitForBytesWritten
returns when data not sent yet.
QTcpSocket::bytesToWrite
also return 0 bytes after calling write function.That is correct, because
QTcpSocket
has handed the data to the operating system and from now on it's out of your control. You normally don't know now what is happenening, only be using tools like Wireshark that integrate deeply in OS functions you can visualize what happens.How can i know when data sent fully?
IMHO you cannot.
Please note that in a distributed network it does not mean much when a TCP packet is sent out, it can have a long way until it's destination. It can even be re-send if the sender does not get an ACK from the receiver.
What you can do, is to give an acknowlegde from the receiver side once it received the data and evaluate that on the sender side.
-
Thanks a lot)