Hmm but i think that I do exactly the same you wrote just in a bit diffrent way but idea is the same, firstly the server writes to the socket using QDataStream out, which uses the QByteArray block. Data is written to the block and the the size of the this block is being put at the beginning of the QDataStream. Then at the client side the first do-while loop waits for "the size" of the expected data(for example: files) the size of "the size" is known thats why this is in the first while: clientSocket->bytesAvailable() < (int)sizeof(quint64). After I get the size of the expected incoming data(for example file) thanks to the blockSize now I can wait for my exact data using second do-while loop, and that is why I am using this: clientSocket->bytesAvailable() < blockSize. This is the mechanism that I'm using here and it really worked great, even in sending 10 MB in one file, and as I remember I've used the example from Qt examples and modified it (mostly changed If-instructions to do-while to get to work with big files). After adding SSL something went wrong and it's strange, becouse I read that I can use QSslSockets like QTcpSockets after reimplementing incomingconnection signal. I think that whole handshake stuff is ok becouse I've checked states of both socket server and client side and they were in right state and were encrypted.
Bookmarks