0
votes

I want to send a 1MB file at 200KB/second (5 second transfer) using a QTcpSocket. The ReadyRead slot function first reads the file size (header), then starts a thread that blocks while reading file_size bytes from the socket. But, since the readyRead slot function ends before the file transfer does, won't there be new calls for the readyRead function (new ReadyReads emitted) that would interfere?

i read here: How to make sure that readyRead() signals from QTcpSocket can't be missed? that while you are in the slot function no new ReadyReads will be emitted.

2

2 Answers

0
votes

an obvious solution to my own problem would be to disconnect() the readyread() signal from the slot function inside the slot function, if that's possible.

0
votes

You do not need to start a separate thread. Just handle every readyRead() signal, and append any new data to the file. Eventually all the file will be received.

You don't need to get the entire transfer in one go, just write the file a chunk at a time.