Hi all

I have two network applications, something like client and server.
On the server side I write data to socket which is in QByteArray.

Qt Code:
  1. qint64 size = socket->write(array);
  2. qDebug() << "written" << size;
To copy to clipboard, switch view to plain text mode 

On the client side in slot which is connected to readyRead signal I first read quint32 which is size of data and then I read data to QByteArray.

Qt Code:
  1. QDataStream socketStream(socket);
  2.  
  3. quint32 size;
  4. socketStream >> size;
  5. qDebug() << "size" << size;
  6. qDebug() << "socketAvailable" << quint32(socket->bytesAvailable());
  7.  
  8. if (quint32(socket->bytesAvailable()) < size)
  9. return;
  10.  
  11. QByteArray array = socket->read(size);
To copy to clipboard, switch view to plain text mode 

So qDebug() on server side give me

Qt Code:
  1. warning: written 17980
  2. warning: written 224
  3. warning: written 135176
To copy to clipboard, switch view to plain text mode 

but on teh client side

Qt Code:
  1. warning: size 17976
  2. warning: socketAvailable 17976
  3.  
  4. warning: size 220
  5. warning: socketAvailable 220
  6.  
  7. warning: size 135172
  8. warning: socketAvailable 98300
To copy to clipboard, switch view to plain text mode 

First four warnings are correct becouse I read size which is 4 bytes so it is smaller but the last two do not match. Every time I write to socket more then 98304 bytes it doesnt let me to read them all and I do not know why. In the second calling of client slot when is readyRead emit again there are all data available but I cant read it exactly becouse I have already read their size before. How can I solve this problem? Thanks.