Hello all,

I'm new to QT, new to this forum too, student programmer, etc. In brief, new.

I tried the following example in order to learned how to do a tcp connection and how to send some bytes too.
example : http://www.qtcentre.org/threads/4820...hrough-sockets , code in the bottom of the page.
Everything work well except data reading from a file.

I wrote (copy) that code in the server part :
Qt Code:
  1. // Send File
  2. QFile inputFile(FILENAME);
  3. QByteArray read;
  4. inputFile.open(QIODevice::ReadOnly);
  5. while(1)
  6. {
  7. read.clear();
  8. read = inputFile.read(32768*8);
  9. qDebug() << "Read : " << read.size();
  10. qDebug() << "Pos : " << inputFile.pos();
  11. if(read.size() == 0)
  12. break;
  13.  
  14. qDebug() << "Written :" << client.write(read);
  15. client.waitForBytesWritten();
  16.  
  17. }
To copy to clipboard, switch view to plain text mode 

So, it works well, but it stop after 3 pass (while) and just sent a certain amount of bytes even if I use whatever file as input.
It seems that is the read = inputFile.read(32768*8) that is wrong, but I'm not sure.

Following is the server output. In the third pass it just read 182276 bytes and the QTCpSocket client.write(read) return -1 this time.
The amount of data received by the client = the amount sent by the server = 706564.

File transfer started
Thread called
Thread Descriptor : 21
Thread : Connected
Read : 262144
Pos : 262144
Written : 262144
Read : 262144
Pos : 524288
Written : 262144
Read : 182276
Pos : 706564
Written : -1
QAbstractSocket::waitForBytesWritten() is not allowed in UnconnectedState
Read : 0
Pos : 706564
QAbstractSocket::waitForDisconnected() is not allowed in UnconnectedState
Thread : File transfer completed
/home/serge/Bureau/tp6-server/tp6-server s'est terminé avec le code 0

Thank you very much for your time.