Try this (I added another flush() between the "file" and "ack" packets):.

Qt Code:
  1. #define TCP_MAXBUF 0x08000 // max TCP send and receive size buffer 32768 (MAX right now)
  2.  
  3. // Send File
  4. do
  5. {
  6. // read file pattly
  7. qint64 bytesRead = vrFile->read((char *)buffer,TCP_MAXBUF);
  8.  
  9. int sentSize = pFPSocket->write(fileBuffer.data(), bytesRead);
  10. pFPSocket->flush();
  11. if(!pFPSocket->waitForBytesWritten(Timeout))
  12. {
  13. theLog->WriteLog(QString("Wait for bytes written timed out"),LOG_LEVEL_ERR);
  14. }
  15. }while(!vrFile->atEnd()) ;
  16. //flush the file packet
  17. pFPSocket->flush();
  18. // Send Ack
  19. QByteArray ackBuffer(7, 0);
  20. QDataStream outAck(&ackBuffer, QIODevice::WriteOnly);
  21.  
  22. outAck << (unsigned char)TCP_DISCONNECT;
  23. outAck << (quint32)1;
  24. outAck << (unsigned char)"¤";
  25.  
  26. int i = sizeof(TCPPacket);
  27. if(pFPSocket->write(ackBuffer.data(),6) < 6 )
  28. {
  29. // ERROR not total ack sent
  30. theLog->WriteLog(QString("Could not store %1, complete ack not sent.").arg(Filename),LOG_LEVEL_ERR);
  31. statusOK = false;
  32. }
  33.  
  34. pFPSocket->flush();
  35. if(!pFPSocket->waitForBytesWritten(Timeout))
  36. {
  37. // ERROR not total ack sent
  38. theLog->WriteLog(QString("Could not store %1, ack bytes not written.").arg(Filename),LOG_LEVEL_ERR);
  39. statusOK = false;
  40. }
To copy to clipboard, switch view to plain text mode