Solved

Delphi Indy Components TCP File transfer ProgressBar question

Posted on 2007-03-27
4
8,243 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
  • 2
  • 2
4 Comments
 
LVL 6

Author Comment

by:ioannisa
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Article by: rfc1180
The Maximum Segment size (MSS) is an important consideration when troubleshooting connectivity via the Internet/Intranet. As the packets are routed via the Internet/Intranet, the packets must traverse through multiple routers in the path between two…
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…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now