Qt solution TcpSoctet read data upon receiving the empty string

 

 

 

 As shown above, the received reply directly to the server after transmitting the message to play, found buff is empty, then the transmission and reception of data can be displayed again Shique. This is strange!

Then I thought, this function should be returned so quickly that the server returns data has not yet arrived, so the need to wait for a while.

 

 

 Official document explains: When data arrives in a buffer within the specified time, the function returns true immediately, otherwise timeout returns false,

Then the wait function of this signal is received readyRead

 

 Readyread signal is called once when the data arrives only, and will not be recycled and waitforreadyread call.

 

Guess you like

Origin www.cnblogs.com/jiguang321/p/11693042.html