QSslSocket::write(QByteArray(.size)) doesn´t fit to signal encryptedBytesWritten(qint64 written)
NobodyAtWeekend last edited by
I have a question for you, which costs me already a good amount of time.
When I sent data by the write function of QSslSocket to an already encrypted connection, the functions returns me exactly the size of the QByteArray I give to the function. So far so good, everything as expected.
The amount of data is around 66000 bytes in that QByteArray. Sometimes it happens, that the signal is emitted twice, because the whole data wasn´t encrypted/sent yet. I want to detect when the whole data is transmitted and therefore I´ve tried to store the initial number of bytes and subtract the written bytes in the slot (for the encryptedBytesWritten signal) every time it is called. But unfortunately is the total number of bytes written larger than the size of the QByteArray which was given to the QSslSocket::write() function.
Is there any reason why the numbers differ? Are more bytes written because of some encryption overhead? Can the number of bytes written be calculated on the size of the QByteArray (for all encryption variants which QSslSocket / openSsl offers)?
Is there maybe another solution how to determine, that all data given to the QSslSocket::write function was sent? I´ve already played around with the functions "encryptedBytesToWrite()" and "bytesToWrite" of the QSslSOcket, but with no success.
I really hope you can help me. Thanks in advance!