PDA

View Full Version : readyRead signal too slow or what?



Morea
6th July 2007, 18:34
I have written a client/server program that communicates, and everything worked as planned, until I found that the server sent two messages very quickly, then the client didn't read both the messages, just the first.
Can this really happen, that the readyRead() signal is emitted two times so fast that it doesn't have a chance to handle them both and just handle one of them?
If so, how to fix it? (I added a second call to the networkreader at the end of the networ reader code if were any data left to read and that seems to work.)

jacek
6th July 2007, 19:11
TCP doesn't know anything about your messages as it passes a stream of data. QTcpSocket might receive more than one message at a time, but it will emit readyRead() only once.

When you read data from the buffer, make sure you read everyting, not just the first message.