Re: [twsocket] Need help with HTTP
> The error I get is it sometimes shuts down before all the > data is actually pumped. Your code fragment is difficult to understand. There are to much noise because of features in your program. You'd better build a simplified code. Anyway, if this can help you, I remind you that OnDataSrnt event doesn't mean the data has been sent out to the remote site but that TWSocket has emptied his buffer to winsock own buffer. Winsock has still to send data and for for ack. There is no way to know that winsock has completely sent everything out and received corresponding ACK, except by closing the connection using linger (this will BLOCK the close operation). -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: "Fastream Technologies" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, September 01, 2006 4:14 PM Subject: [twsocket] Need help with HTTP > Hello, > > In the OnDocData of THttpCli descendent, I pause the THTtpCli and > Send(Buffer, Len) to the THttpConnection (this is a proxy server). The > problem is at ConnectionDataAvailable of THttpConnection, I cannot be sure > that all the data is sent or is it complete because sometimes packets are > merged and I cannot be sure how much of the downloaded data is actually > sent > to the client. Here is the code: > > void __fastcall httpServerClientClass::HTTPClientDocData(TObject *Sender, > > Pointer Buffer, > > int Len) > > { > > if(compressionType <= 0 && !absURLTranslation && (!noContentLength || > transferEncodingChunked)) > > { > > HTTPClient->PauseCS(false); > > sendDataToRequesterClient(Buffer, Len); > > } > > else > > { > > aggregateDataForGZipSending(Buffer, Len); > > } > > } > > //--- > > void __fastcall httpServerClientClass::sendDataToRequesterClient(Pointer > buffer, int len) > > { > > if(cacheType == cacheJustAdd) > > { > > lockCriticalSection(objectCacheCS); > > objectCache->Position = cachePosition; > > objectCache->Write(buffer, len); > > cachePosition = objectCache->Position; > > releaseCriticalSection(objectCacheCS); > > } > > int Count = 0; > > if(transferEncodingChunked && State == wsConnected && lastCommand != > httpCommandHEAD && protocolStatus[1] != '3') > > { > > Count = SendStr("\r\n" + String(IntToHex(len, 1)) + "\r\n"); > > bytesReceived += Count; > > } > > if(State == wsConnected) > > { > > Count += Send(buffer, len); > > DataSent += Count; // count data which is sent by the last buffer > > if(transferEncodingChunked && DataSent >= DataToBeSent) > > { > > if(protocolStatus[1] != '3' && lastCommand != httpCommandHEAD) > > { > > SendStr("\r\n0\r\n\r\n"); > > bytesReceived += 7; > > } > > } > > countTransferredPer100ms(Count); > > setLastActionTime(); > > } > > } > > //--- > > void __fastcall httpServerClientClass::HTTPClientDocEnd(TObject *Sender) > > { > > if(HTTPClient) > > HTTPClient->setState(httpReady); > > if(noContentLength || transferEncodingChunked) > > if(cacheType == cacheJustAdd) > > cache->setActualFileSize(cacheURL); > > if(compressionType > 0 || absURLTranslation || (noContentLength && > !transferEncodingChunked)) > > SendDocumentWGZip(); > > else > > { > > if(transferEncodingChunked) > > chunkedTransferEnded = true; > > } > > } > > //--- > > > > void __fastcall > httpServerClientClass::ConnectionDataSentCleartextTunnel(TObject *Sender, > WORD Error) > > { > > ++bytesSent; > > if( > > ( > > (!transferEncodingChunked && DataSent >= DataToBeSent && DataPrevSent == > DataSent) > > || > > (transferEncodingChunked && chunkedTransferEnded) > > ) > > || > > Error > > || > > (lastCommand == httpCommandHEAD || protocolStatus[1] == '3') > > ) > > { > > objectPosition = DataSent; > > socketError = Error; > > endOfResponse(); > > if(!FKeepAlive || Error) > > Shutdown(1); > > return; > > } > > if(HTTPClient) > > HTTPClient->ResumeCSIfNotPausedByThrottler(); > > } > > > > The error I get is it sometimes shuts down before all the data is actually > pumped. > > Hope you can help. > > Best Regards, > > SZ > > -- > 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 -- 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
Re: [twsocket] Handling redirects
> PS: I will gladly pay a few dollars for a good help file :) I would prefer you help writing the help. There is a project at http://wiki.overbyte.be. We need people to write as much as they can. If you don't know the component, no problem: you can take the source code and simply create all entries for properties, methods and events whithout actually creating the article. Someone else will add the actual description. Let me know - or anybody else - want write permission to the wiki. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be -- 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
Re: [twsocket] FTP resuming transfers
I don't see any problem truncating your file before resuming the transfert. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: "Dan" <[EMAIL PROTECTED]> To: "'ICS support mailing'" Sent: Friday, September 01, 2006 8:37 PM Subject: Re: [twsocket] FTP resuming transfers > Its possible that a client can rollback some part of the file incase the > end > (where the transfer was interrupted) is corrupt. Some clients do a REST > to > eg. 4kb less than the current size. I think it makes more sense to set > the > position and size when the transfer begins following a REST command. > > Dan > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Francois PIETTE > Sent: 31 August 2006 20:34 > To: ICS support mailing > Subject: Re: [twsocket] FTP resuming transfers > >>> Do you mean it could be smaller than his previous size >>> when resuming a transfert ? >> >> Yes, that's what I mean and the question :)) > > If a resumed transfer is smaller than the existing file, then there is a > problem ! It is likely that the start of the local file is no more the > same > as the copy on the server and the whole transfert is corrupted. > > -- > [EMAIL PROTECTED] > The author for the freeware multi-tier middleware MidWare > The author of the freeware Internet Component Suite (ICS) > http://www.overbyte.be > > > - Original Message - > From: "Arno Garrels" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Thursday, August 31, 2006 9:18 PM > Subject: Re: [twsocket] FTP resuming transfers > > >> Francois PIETTE wrote: I reworked the streams stuff in both FTP C/S today and fixed some bugs, everything was tested sucessfully with 64-bit streams. There's only one question I cannot answer by myself. TFileStream in mode fmOpenWrite does not set its size to current position when it is destroyed. Won't it make sense to set stream size explizitely to the current position in the FtpCli/FtpSrv when data connection is closed (although I guess that it won't work in D2 since method Size exists since D3)? What do you think? >>> >>> Do you mean it could be smaller than his previous size >>> when resuming a transfert ? >> >> Yes, that's what I mean and the question :)) >> >>> I don't think so. >>> >>> -- >>> Contribute to the SSL Effort. Visit >>> http://www.overbyte.be/eng/ssl.html -- >>> [EMAIL PROTECTED] >>> http://www.overbyte.be >> -- >> 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 > > -- > 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 > > > -- > 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 -- 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
Re: [twsocket] Need help with HTTP
Again my private email spam blocked.. :( Anyway, thanks for the reply. Will look at it later as my brain got fragmented... Best Regards, Gorkem Ates - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Saturday, September 02, 2006 11:00 AM Subject: Re: [twsocket] Need help with HTTP :> The error I get is it sometimes shuts down before all the : > data is actually pumped. : Your code fragment is difficult to understand. There are to much noise : because of features in your program. You'd better build a simplified code. : : Anyway, if this can help you, I remind you that OnDataSrnt event doesn't : mean the data has been sent out to the remote site but that TWSocket has : emptied his buffer to winsock own buffer. Winsock has still to send data and : for for ack. There is no way to know that winsock has completely sent : everything out and received corresponding ACK, except by closing the : connection using linger (this will BLOCK the close operation). : : -- : Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html : -- : [EMAIL PROTECTED] : http://www.overbyte.be : : : : - Original Message - : From: "Fastream Technologies" <[EMAIL PROTECTED]> : To: "ICS support mailing" : Sent: Friday, September 01, 2006 4:14 PM : Subject: [twsocket] Need help with HTTP : : : > Hello, : > : > In the OnDocData of THttpCli descendent, I pause the THTtpCli and : > Send(Buffer, Len) to the THttpConnection (this is a proxy server). The : > problem is at ConnectionDataAvailable of THttpConnection, I cannot be sure : > that all the data is sent or is it complete because sometimes packets are : > merged and I cannot be sure how much of the downloaded data is actually : > sent : > to the client. Here is the code: : > : > void __fastcall httpServerClientClass::HTTPClientDocData(TObject *Sender, : > : > Pointer Buffer, : > : > int Len) : > : > { : > : > if(compressionType <= 0 && !absURLTranslation && (!noContentLength || : > transferEncodingChunked)) : > : > { : > : > HTTPClient->PauseCS(false); : > : > sendDataToRequesterClient(Buffer, Len); : > : > } : > : > else : > : > { : > : > aggregateDataForGZipSending(Buffer, Len); : > : > } : > : > } : > : > //--- : > : > void __fastcall httpServerClientClass::sendDataToRequesterClient(Pointer : > buffer, int len) : > : > { : > : > if(cacheType == cacheJustAdd) : > : > { : > : > lockCriticalSection(objectCacheCS); : > : > objectCache->Position = cachePosition; : > : > objectCache->Write(buffer, len); : > : > cachePosition = objectCache->Position; : > : > releaseCriticalSection(objectCacheCS); : > : > } : > : > int Count = 0; : > : > if(transferEncodingChunked && State == wsConnected && lastCommand != : > httpCommandHEAD && protocolStatus[1] != '3') : > : > { : > : > Count = SendStr("\r\n" + String(IntToHex(len, 1)) + "\r\n"); : > : > bytesReceived += Count; : > : > } : > : > if(State == wsConnected) : > : > { : > : > Count += Send(buffer, len); : > : > DataSent += Count; // count data which is sent by the last buffer : > : > if(transferEncodingChunked && DataSent >= DataToBeSent) : > : > { : > : > if(protocolStatus[1] != '3' && lastCommand != httpCommandHEAD) : > : > { : > : > SendStr("\r\n0\r\n\r\n"); : > : > bytesReceived += 7; : > : > } : > : > } : > : > countTransferredPer100ms(Count); : > : > setLastActionTime(); : > : > } : > : > } : > : > //--- : > : > void __fastcall httpServerClientClass::HTTPClientDocEnd(TObject *Sender) : > : > { : > : > if(HTTPClient) : > : > HTTPClient->setState(httpReady); : > : > if(noContentLength || transferEncodingChunked) : > : > if(cacheType == cacheJustAdd) : > : > cache->setActualFileSize(cacheURL); : > : > if(compressionType > 0 || absURLTranslation || (noContentLength && : > !transferEncodingChunked)) : > : > SendDocumentWGZip(); : > : > else : > : > { : > : > if(transferEncodingChunked) : > : > chunkedTransferEnded = true; : > : > } : > : > } : > : > //--- : > : > : > : > void __fastcall : > httpServerClientClass::ConnectionDataSentCleartextTunnel(TObject *Sender, : > WORD Error) : > : > { : > : > ++bytesSent; : > : > if( : > : > ( : > : > (!transferEncodingChunked && DataSent >= DataToBeSent && DataPrevSent == : > DataSent) : > : > || : > : > (transferEncodingChunked && chunkedTransferEnded) : > : > ) : > : > || : > : > Error : > : > || : > : > (lastCommand == httpCommandHEAD || protocolStatus[1] == '3') : > : > ) : > : > { : > : > objectPosition = DataSent; : > : > socketError = Error; : > : > endOfResponse(); : > : > if(!FKeepAlive || Error) : > : > Shutdown(1); : > : > return; : > : > } : > : > if(HTTPClient) : > : > HTTPClient->ResumeCSIfNotPausedByThrottler(); : > : > } : > : > : > : > The error I get is it sometimes shuts down before all
Re: [twsocket] Need help with HTTP
Hello, I have debugged the code to this point: { 26/11/2003: next 2 lines commented out to allow receiving data outside } { of any request (server push) } {if FState <> httpWaitingHeader then Exit; }{ Should never occur ! } while FReceiveLen > 0 do begin I := Pos(#10, FReceiveBuffer); if I <= 0 then begin break; // HERE end; This occurs when I reuse the same THttpCli connection, first HEAD then GET. I call InternalClear() and set the state to httpReady in between. I also check for any disconnection and abort then. I saw in OnDocData, header being in the Buffer variable. And in this code, there is no header/just data in FReceiveBuffer. I am puzzled and suffer a headache. ;0( Regards, SZ - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Saturday, September 02, 2006 11:00 AM Subject: Re: [twsocket] Need help with HTTP :> The error I get is it sometimes shuts down before all the : > data is actually pumped. : Your code fragment is difficult to understand. There are to much noise : because of features in your program. You'd better build a simplified code. : : Anyway, if this can help you, I remind you that OnDataSrnt event doesn't : mean the data has been sent out to the remote site but that TWSocket has : emptied his buffer to winsock own buffer. Winsock has still to send data and : for for ack. There is no way to know that winsock has completely sent : everything out and received corresponding ACK, except by closing the : connection using linger (this will BLOCK the close operation). : : -- : Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html : -- : [EMAIL PROTECTED] : http://www.overbyte.be : : : : - Original Message - : From: "Fastream Technologies" <[EMAIL PROTECTED]> : To: "ICS support mailing" : Sent: Friday, September 01, 2006 4:14 PM : Subject: [twsocket] Need help with HTTP : : : > Hello, : > : > In the OnDocData of THttpCli descendent, I pause the THTtpCli and : > Send(Buffer, Len) to the THttpConnection (this is a proxy server). The : > problem is at ConnectionDataAvailable of THttpConnection, I cannot be sure : > that all the data is sent or is it complete because sometimes packets are : > merged and I cannot be sure how much of the downloaded data is actually : > sent : > to the client. Here is the code: : > : > void __fastcall httpServerClientClass::HTTPClientDocData(TObject *Sender, : > : > Pointer Buffer, : > : > int Len) : > : > { : > : > if(compressionType <= 0 && !absURLTranslation && (!noContentLength || : > transferEncodingChunked)) : > : > { : > : > HTTPClient->PauseCS(false); : > : > sendDataToRequesterClient(Buffer, Len); : > : > } : > : > else : > : > { : > : > aggregateDataForGZipSending(Buffer, Len); : > : > } : > : > } : > : > //--- : > : > void __fastcall httpServerClientClass::sendDataToRequesterClient(Pointer : > buffer, int len) : > : > { : > : > if(cacheType == cacheJustAdd) : > : > { : > : > lockCriticalSection(objectCacheCS); : > : > objectCache->Position = cachePosition; : > : > objectCache->Write(buffer, len); : > : > cachePosition = objectCache->Position; : > : > releaseCriticalSection(objectCacheCS); : > : > } : > : > int Count = 0; : > : > if(transferEncodingChunked && State == wsConnected && lastCommand != : > httpCommandHEAD && protocolStatus[1] != '3') : > : > { : > : > Count = SendStr("\r\n" + String(IntToHex(len, 1)) + "\r\n"); : > : > bytesReceived += Count; : > : > } : > : > if(State == wsConnected) : > : > { : > : > Count += Send(buffer, len); : > : > DataSent += Count; // count data which is sent by the last buffer : > : > if(transferEncodingChunked && DataSent >= DataToBeSent) : > : > { : > : > if(protocolStatus[1] != '3' && lastCommand != httpCommandHEAD) : > : > { : > : > SendStr("\r\n0\r\n\r\n"); : > : > bytesReceived += 7; : > : > } : > : > } : > : > countTransferredPer100ms(Count); : > : > setLastActionTime(); : > : > } : > : > } : > : > //--- : > : > void __fastcall httpServerClientClass::HTTPClientDocEnd(TObject *Sender) : > : > { : > : > if(HTTPClient) : > : > HTTPClient->setState(httpReady); : > : > if(noContentLength || transferEncodingChunked) : > : > if(cacheType == cacheJustAdd) : > : > cache->setActualFileSize(cacheURL); : > : > if(compressionType > 0 || absURLTranslation || (noContentLength && : > !transferEncodingChunked)) : > : > SendDocumentWGZip(); : > : > else : > : > { : > : > if(transferEncodingChunked) : > : > chunkedTransferEnded = true; : > : > } : > : > } : > : > //--- : > : > : > : > void __fastcall : > httpServerClientClass::ConnectionDataSentCleartextTunnel(TObject *Sender, : > WORD Error) : > : > { : > : > ++bytesSen
[twsocket] THTTPServer compiled by FPC on Linux
Hello, I am using Free Pascal Compiler (Lazarus IDE) and am having trouble with the compiling anything using THTTPServer on Linux platform, specifically Im using Fedora 5, but I think it is a generic linux problem since the error is "can't find Windows unit". I'm guessing this is a unit specific to Win32. It compiles fine on Windows but on Linux I get an error about not being able to find Windows unit. Are people commonly compiling ICS on linux (Kylix or FPC)? I'm not sure if this is due to something in ICS or a FPC setting... And before I go searching for I thought I'd ask to see if anyone else has solved this. Many thanks in advance, K. -- 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
Re: [twsocket] THTTPServer compiled by FPC on Linux
There is a ICS-Kylix version available (see website). Not all components are there are development is more or less in standby. ICS for Windows make use of Winsock asynchronous mode and Windows messages none are available on Linux. ICS for Linux replace built in asynchronous operation by thread and implement a kind of message system. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: "Kris Leech" <[EMAIL PROTECTED]> To: Sent: Saturday, September 02, 2006 4:07 PM Subject: [twsocket] THTTPServer compiled by FPC on Linux > Hello, I am using Free Pascal Compiler (Lazarus IDE) and am having > trouble with the compiling anything using THTTPServer on Linux platform, > specifically Im using Fedora 5, but I think it is a generic linux > problem since the error is "can't find Windows unit". I'm guessing this > is a unit specific to Win32. > > It compiles fine on Windows but on Linux I get an error about not being > able to find Windows unit. > Are people commonly compiling ICS on linux (Kylix or FPC)? > I'm not sure if this is due to something in ICS or a FPC setting... > And before I go searching for I thought I'd ask to see if anyone else > has solved this. > > Many thanks in advance, K. > > > > > -- > 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 -- 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
[twsocket] TCP question
Hello, if a client on a LAN sends a packet with e.g. 512 Bytes and TCP splits it up internaly to e.g. 4x128 Bytes will the receiver get 4x the OnDataAvailable event, or 1x with the whole 512 Byte? So needs the sender to have a larger buffer to be able to concatenate such packets before he can check and process them? if yes, has anybody a ringbuffer implementation he would share? Otherwise I'm toying with the idea to use a string as buffer so I can add chars and delete some from the beginning of the buffer as needed, but I don't know whether memory fragmentation is a issue here (D2006 with FastMM). Greetings Markus -- 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
Re: [twsocket] TCP question
> if a client on a LAN sends a packet with e.g. 512 Bytes and TCP splits > it up internaly to e.g. 4x128 Bytes will the receiver get 4x the > OnDataAvailable event, or 1x with the whole 512 Byte? You can't predict. The only thing which is sure is that you'll receive all data in correct order. Packet fragmentation (or merging) depends on a lot of factors. One being your application. If it is slow processing packets, winsock continue to receive packets in the bacground, fill his buffer (8KB by default) and will deliver as much as possible at once. > So needs the sender to have a larger buffer to be able to concatenate > such packets before he can check and process them? You mean the receiver ? > if yes, has anybody a ringbuffer implementation he would share? You may use a simple GetMem and RellocMem to enlarge the buffer should it become too small. Be aware that ReallocMem may copy your data in another location. > Otherwise I'm toying with the idea to use a string as buffer so > I can add chars and delete some from > the beginning of the buffer as needed, Using string is a bad idea. Performance will not be there ! Avoid moving data around. Use pointers (or index in an array). That will be efficient. > but I don't know whether memory > fragmentation is a issue here (D2006 with FastMM). Fragmentation will always exists. No matter how intelligent is the memory manager. You should always think about what you do with your data. The less you move it around, the faster will be your program. Avoid allocating/freeing memory too frequently. Reuse allocated memory as much. If you want your code to be portable to .NET, use "array of byte" as much and use integer index to the array. For easy use, define "TBytes = array of bytes;". Avoid GetMem/FreeMem/ReallocMem , FillChar, Move and the likes. Avoid building strings character by character, this is incredibly inefficient in .NET (StringBuilder class has been created for such handling). -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be -- 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
Re: [twsocket] Need help with HTTP
Hello, First of all, I would like to thank Ronny for his kind words on private email. (He finds my messages helpful! :) ). After a week of bug hunting I found the problem: I no longer call Abort() if the existing connection's IP/port is different than target's--I just let the component manage it. Best Regards, SZ - Original Message - From: "Fastream Technologies" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Saturday, September 02, 2006 4:52 PM Subject: Re: [twsocket] Need help with HTTP : Hello, : : I have debugged the code to this point: : : : { 26/11/2003: next 2 lines commented out to allow receiving data outside } : { of any request (server push) } : {if FState <> httpWaitingHeader then :Exit; }{ Should never occur ! } : :while FReceiveLen > 0 do begin :I := Pos(#10, FReceiveBuffer); :if I <= 0 then begin :break; // HERE :end; : : This occurs when I reuse the same THttpCli connection, first HEAD then GET. : I call InternalClear() and set the state to httpReady in between. I also : check for any disconnection and abort then. : : I saw in OnDocData, header being in the Buffer variable. And in this code, : there is no header/just data in FReceiveBuffer. I am puzzled and suffer a : headache. ;0( : : Regards, : : SZ : : - Original Message - : From: "Francois PIETTE" <[EMAIL PROTECTED]> : To: "ICS support mailing" : Sent: Saturday, September 02, 2006 11:00 AM : Subject: Re: [twsocket] Need help with HTTP : : ::> The error I get is it sometimes shuts down before all the :: > data is actually pumped. :: Your code fragment is difficult to understand. There are to much noise :: because of features in your program. You'd better build a simplified code. :: :: Anyway, if this can help you, I remind you that OnDataSrnt event doesn't :: mean the data has been sent out to the remote site but that TWSocket has :: emptied his buffer to winsock own buffer. Winsock has still to send data : and :: for for ack. There is no way to know that winsock has completely sent :: everything out and received corresponding ACK, except by closing the :: connection using linger (this will BLOCK the close operation). :: :: -- :: Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html :: -- :: [EMAIL PROTECTED] :: http://www.overbyte.be :: :: :: :: - Original Message - :: From: "Fastream Technologies" <[EMAIL PROTECTED]> :: To: "ICS support mailing" :: Sent: Friday, September 01, 2006 4:14 PM :: Subject: [twsocket] Need help with HTTP :: :: :: > Hello, :: > :: > In the OnDocData of THttpCli descendent, I pause the THTtpCli and :: > Send(Buffer, Len) to the THttpConnection (this is a proxy server). The :: > problem is at ConnectionDataAvailable of THttpConnection, I cannot be : sure :: > that all the data is sent or is it complete because sometimes packets : are :: > merged and I cannot be sure how much of the downloaded data is actually :: > sent :: > to the client. Here is the code: :: > :: > void __fastcall httpServerClientClass::HTTPClientDocData(TObject : *Sender, :: > :: > Pointer Buffer, :: > :: > int Len) :: > :: > { :: > :: > if(compressionType <= 0 && !absURLTranslation && (!noContentLength || :: > transferEncodingChunked)) :: > :: > { :: > :: > HTTPClient->PauseCS(false); :: > :: > sendDataToRequesterClient(Buffer, Len); :: > :: > } :: > :: > else :: > :: > { :: > :: > aggregateDataForGZipSending(Buffer, Len); :: > :: > } :: > :: > } :: > :: > : //--- :: > :: > void __fastcall httpServerClientClass::sendDataToRequesterClient(Pointer :: > buffer, int len) :: > :: > { :: > :: > if(cacheType == cacheJustAdd) :: > :: > { :: > :: > lockCriticalSection(objectCacheCS); :: > :: > objectCache->Position = cachePosition; :: > :: > objectCache->Write(buffer, len); :: > :: > cachePosition = objectCache->Position; :: > :: > releaseCriticalSection(objectCacheCS); :: > :: > } :: > :: > int Count = 0; :: > :: > if(transferEncodingChunked && State == wsConnected && lastCommand != :: > httpCommandHEAD && protocolStatus[1] != '3') :: > :: > { :: > :: > Count = SendStr("\r\n" + String(IntToHex(len, 1)) + "\r\n"); :: > :: > bytesReceived += Count; :: > :: > } :: > :: > if(State == wsConnected) :: > :: > { :: > :: > Count += Send(buffer, len); :: > :: > DataSent += Count; // count data which is sent by the last buffer :: > :: > if(transferEncodingChunked && DataSent >= DataToBeSent) :: > :: > { :: > :: > if(protocolStatus[1] != '3' && lastCommand != httpCommandHEAD) :: > :: > { :: > :: > SendStr("\r\n0\r\n\r\n"); :: > :: > bytesReceived += 7; :: > :: > } :: > :: > } :: > :: > countTransferredPer100ms(Count); :: > :: > setLastActionTime(); :: > :: > } :: > :: > } :: > :: > : //--- :: > :: > void __fastcall httpServerClientClass::HTTPClientDocEnd(TObjec