Solved

Delphi Indy Components TCP File transfer ProgressBar question

Posted on 2007-03-27
4
8,346 Views
Last Modified: 2013-11-23
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?
0
Comment
Question by:ioannisa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Author Comment

by:ioannisa
ID: 18799241
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
 
LVL 19

Accepted Solution

by:
Barthax earned 50 total points
ID: 18806231
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
 
LVL 6

Author Comment

by:ioannisa
ID: 18807002
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
 
LVL 19

Expert Comment

by:Barthax
ID: 18815499
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

Featured Post

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question