Hi, gabizzz. The first slot doesn't have to be a loop, as socket.readAll() always reads everything in the buffer.

So instead try this, it should do the same:

Qt Code:
  1. void Dialog::tcpReady()
  2. {
  3. QFile file("linux.png");
  4. file.open(QIODevice::WriteOnly + QIODevice::Append);
  5. QDataStream ds(&file);
  6. ds.setVersion(QDataStream::Qt_4_6);
  7. ds << socket.readAll();
  8. file.close();
  9. }
To copy to clipboard, switch view to plain text mode 

Better check you error conditions though. If the file open fails, your program will misbehave. I slipped in QIODevice::Append, assuming you don't want to overwrite your file for every received packet. For improved performance it's best to leave the file open and not reopen it for each packet though.

The rest of the code looks quite right (I haven't seen the whole source code).