About this problem for a long time, before doing small exercises, with Qtcpsocket write () a data, and then the receiver as long as emit a readyread () signal and then use Qtcpsocket Read (). The receiver responds to the readyread signal as soon as the sender is write once. In fact, this is not the case, Readyread will not know that the sender called several write, it is only responsible for the arrival of data to trigger, and when you really receive, you may have been able to receive all the data. This depends on the amount of information you send, if very few, such as sending a few bytes of data of course no problem, once Readyread can read all the data but remember, this is not inevitable. In addition Readread can read how much data is uncertain, it depends on your speed, and your computer's performance.
For example, I am programming with the sender while () continuously to the network data transmission, the file data volume is very large, it is necessary to use Waitforbyteswritten to do a wait, This is when the last write () is finished before continuing with the next write () so that the data is not leaking or confusing. There is also a problem is to transfer data must first tell the receiver how much data is sent, that is, when the real data in the head with 2 bytes (quint16) or four bytes (quint32) to store the size of the transmitted data. The receiver is based on the size of the transmission data and the size of each bytesavailable () In contrast if the small on the constant trigger emit signal, in to receive, know the final received total data and the sender's data size is consistent with the instructions received completed. This solves the problem of sending and receiving large amount of data continuously.