hi,

i have a created two applications, e.i, client and server applications. I have noticed in my client app that after several minutes it slows down in receiving files. The server has already sent or written the data in the socket but my client app doesnt receive it immediately, i should wait about 10 -20 seconds before the data is received.

here is my code under socketReadyRead function in client side:

Qt Code:
  1. QDataStream in(clientSocket);
  2. in.setVersion(QDataStream::Qt_4_4);
  3. if (blockSize == 0) {
  4. if (clientSocket->bytesAvailable() < (int)sizeof(quint32))
  5. return;
  6. in >> blockSize;
  7. }
  8.  
  9. if (clientSocket->bytesAvailable() < blockSize)
  10. return;
  11.  
  12. QByteArray bytedata;
  13. in >> bytedata; // get the data
  14.  
  15. QString fileName;
  16. in >> fileName; // get the filename
  17. QStringList f = fileName.split("<hermz>");
  18. QString ipDir = f[0]; // get the receiver branch ip
  19. fileName = f[1]; // get the actual filename
  20. QString WRITEPATH = sOutPath + "/" + ipDir + "/" + fileName;
  21.  
  22. QDir dir;
  23. if(!dir.exists(sOutPath + "/" + ipDir))
  24. dir.mkdir(sOutPath + "/" + ipDir);
  25.  
  26. QFile fWrite(WRITEPATH);
  27. if (fWrite.open(QIODevice::WriteOnly )){
  28. fWrite.write(bytedata);
  29. fWrite.close();
  30. }
  31. logToMonitor( fileName + " received", "blue", 2);
  32.  
  33. blockSize = 0;
To copy to clipboard, switch view to plain text mode 

please help, thnks...