Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Indy's write buffering question

www.cryer.info
Managed Newsgroup Archive

Indy's write buffering question

Subject:Indy's write buffering question
Posted by:"Sir Stephen" (sir-steph..@sir-stephen.com)
Date:25 Jun 2006 17:17:57

I'm trying to understand how Indy's buffering system works :-)

I just created a small app which transfers files between two
computers by using TIdTCPClient/TIdTCPServer. I also used a nice
progressbar which is updated during uploads and downloads. The
code is threaded and works fine !

My problem is to update the progress bar. I used the OnWork event
handlers to connect all my code which update it. When I receive
streams, it works. The progress bar show an accurate estimation
of the bytes transferred for the current file. But when I send
streams, it bugs. I have stepped through the Indy code and I've
seen that by default, when streams are sent they are buffered
(FWriteBuffer.Write(ABuffer) in IdIOHandler.pas). It seems
indeed, when I debug my application, that the stream is quickly
put into the buffer (6Mb of data are eaten by the Write()
function in less of 6 seconds !) before that the function
returns. So, when DoWork() is called (inside
TIdIOHandler.Write()) it doesn't not reflect how many bytes has
been sent *on the connection* but how many bytes has been put
into the write buffer. Am I wrong ? If it's true, it's a
problem to update my progressbar since it will not shows how many
bytes have really been wrote on the connection.

To update my progressbar properly I suppose I should disable
write buffering... Is there the only solution I have ? How can I
do that ?...

Any hints appreciated !

Cheers

--Sir Stephen

And sorry for my bad english !

Replies:

www.cryer.info
Managed Newsgroup Archive