Hello, We have coded the following in SendNextDataChunk:
... if(Count > 0 && (!clientObject->totalByteCount64 || (clientObject->RestartPos64 + clientObject->ByteCount64 <= clientObject->totalByteCount64))) { if(clientObject->downloadTransferRate) { int delay = clientObject->smThrottle->Delay(clientObject->ByteCount64, clientObject->downloadTransferRate, true); if(delay > 0) { clientObject->lastPauseTime = Now(); clientObject->milliSecsToResume = delay; clientObject->paused = true; clientObject->DataSocket->Pause(); } } if(!clientObject->paused) { if(clientObject->ZMode) { unsigned long destLen = clientObject->BlockSize * 2; DWORD Param = Z_FULL_FLUSH; if(Count < clientObject->BlockSize) Param = Z_FINISH; clientObject->processDeflateZip(clientObject->RcvBuf, Count, (unsigned char*)clientObject->zlibBuffer, destLen, Param); // concentrate HERE Data->Send(clientObject->zlibBuffer, destLen); clientObject->ByteCount64 += destLen; } else { Data->Send(clientObject->RcvBuf, Count); clientObject->ByteCount64 += Count; } } else { clientObject->CachePosition -= Count; } } where, int __fastcall ftpServerClientClass::processDeflateZip(unsigned char *source, unsigned int sourceLen, unsigned char *dest, unsigned long &destLen, DWORD Param) { ((z_stream*)deflater)->next_in = source; // make sure next_in is not 0 in all cases ((z_stream*)deflater)->avail_in = sourceLen; ((z_stream*)deflater)->next_out = dest; ((z_stream*)deflater)->avail_out = destLen; ((z_stream*)deflater)->total_in = 0; ((z_stream*)deflater)->total_out = 0; int Res = deflate(((z_stream*)deflater), Param); destLen = ((z_stream*)deflater)->total_out; return Res; } //--------------------------------------------------------------------------- I correctly inited the deflate stream. It works very well with files less than a few MBs but for more than that it forgets the last less than buffersize data. For example, The file is 13.302.505 bytes, it downloads the max times of 8192 which is 13.287.424. Also the full_debug approach Peter used here is written in Zlib.h as "degraded" performance since it may not be using all of the output buffer. Any idea how this could be in sendnextdatachunk context? I studied FileZilla code but it is even worse (much more complex and hard to test--error prone). Best Regards, SubZ -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be