The semantics of QIODevice
are such that readyRead
signal simply means that there is likely data to be available for reading. It doesn't mean that there's surely data available, and it doesn't mean that a particular amount of data is guaranteed to be available. Implementations certainly do their best to avoid spurious signals, but they are free to issue any number of "spurious" ones. It would be a much worse problem (a bug, in fact!) if a readyRead
signal was missed.
What you're supposed to do is to read whatever data is available when you get the signal. That's all. There are absolutely no guarantees that you will get the data in any particular "chunking". For example, if one end of a connection does a single, 1kByte write, the other end of the connection may get any number of readyRead
signals.
All that is guaranteed is that if you only read data when you get a readyRead
signal, you won't miss any data - thus you don't need to do reads from anywhere but a slot connected to a readyRead
signal.
So, what you're seeing is perfectly OK. You need to handle any amount of data being available when a readyRead
fires. Including zero bytes.