Just for the record :

Finally, I managed my QAbstractSocket::waitForBytesWritten() with the following code from the QT documentation and I don't get the error message
Qt Code:
  1. client.disconnectFromHost();
  2. if(client.state() == QAbstractSocket::UnconnectedState ||
  3. client.waitForDisconnected(1000))
  4. qDebug("Disconnected!");
  5. else
  6. qDebug() << "Error when DisconnectFromHost :" << client.error();
To copy to clipboard, switch view to plain text mode 

The was no "read" error at all. In fact, the problem was in the client side.
I just forget to read in the QTcpSocket until there was not data. In the exemple in the link that I posted, the client read just one time.
This way, the server read and write data and the client read it.
The second time the server read data and write it in the TCPSocket, but it is not read or flushed because the client doesn't read it.
And the third time, the server read data and it is not able to write it in the socket.

This is the new client code. The previous code didn't have the while(client->waitForReadyRead()) but just a one time waitForReadyRead. That was my problem from the beginning.
Qt Code:
  1. QFile file(filename);
  2. if(!(file.open(QIODevice::Append)))
  3. {
  4. qDebug("File connot be opened.");
  5. exit(0);
  6. }
  7. else
  8. {
  9. while(client->waitForReadyRead())
  10. {
  11. QByteArray read = client->read(client->bytesAvailable());
  12. qDebug() << "Read : " << read.size();
  13. qDebug() << "Written : " << file.write(read);
  14. }
  15. }
  16.  
  17.  
  18. file.close();
To copy to clipboard, switch view to plain text mode 

Thanks for all.