Delphi Indy Components TCP File transfer ProgressBar question

I am using Delphi 7, Indy components with TCPClient and TCPServer for file transfer.

I transfer various size files.  Happily from your answered questions I saw that I have to exclude
AThread.Connection.OpenWriteBuffer; and
AThread.Connection.CloseWriteBuffer;

and get something like
//AThread.Connection.OpenWriteBuffer; and
AThread.Connection.WriteStream(FileStream);
//AThread.Connection.CloseWriteBuffer;


for large files so they are not written in one chunk.  Now that I've left only the
AThread.Connection.WriteStream(FileStream);

my question is how I can get from there the percentage of the written file to show it on a progress bar on the uploader side, as well how to show a progress bar for the download on the client side.

What I got on the client side is...

FileStream:= TFileStream.Create(fname, fmCreate);
while connected do
          ReadStream(FileStream, -1, true);
FreeAndNil(FileStream);

so, how do I get a progressbar from there?
LVL 6
Ioannis AnifantakisSoftware EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ioannis AnifantakisSoftware EngineerAuthor Commented:
by the way... I see I spend points....
What does this mean? I have a maximum I should not exceed per month or per payment? What does this mean?  I just joined today and I don't know anything about all these...  Also is there any place I can post some delphi code I've written with some funtions that make everyday tasks easier?

(Please don't let my 2nd question overcome my first... thanx)

:)
0
BarthaxCommented:
Hi ioannisa,

I've been out of touch with the recent Indy stuff, but par-for-the-course with Indy components were a suite of events, typically called On<name>.  Look for these components for the object & you'll probably find an OnProgress (or similar) which will be called on every so-often.  Note that there exists a problem with TCP streams, in that there is no guaranteed size, so expecting the OnProgress callback (or whatever it is) to give you a percentage is not going to happen.

EE works by using points to spend on questions you want to ask & the accepted/assisted answers to the questions get the points you offer.  Review the FAQ ( http://www.experts-exchange.com/help.jsp#hs1 ) for further information.  There is a community section of topics - you might like to post you code somewhere there, but it's not something I've particular thought about...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ioannis AnifantakisSoftware EngineerAuthor Commented:
I managed to use the onWork even on the client side, the code follows

procedure TfrmDWS.IdTCPClient1Work(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCount: Integer);
begin
    if AWorkMode=wmRead then begin
        ProgBar.Position:=ProgBar.Position+(AWorkCount div 1024);
        Edit2.Text:=intToStr(ProgBar.Position);
        update;
    end;
end;

This works and thank you very much for your redirection...
PROBLEM SOLVED!

Just another question if possible, is it possible to do the work as well inverted? That is the up to now was to send some file from the client to the server.  Now is it the same to send something from the client to the server? (I haven't tried anythig yet, just ask if there is something I don't know yet).

The point is I want to make some CRM application, and on every answer thread the user can "attach" some file (the client-to-server file transfer) and the viewers request files they see attached (the server-to-client file transfer which is already solved)
0
BarthaxCommented:
The reverse is precisely that: the client is performing the write and the server is performing the read.  I would expect the manner in which you implement your send & receive should be in the same unit & that unit is shared between your server & client implementations...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.