Solved

Delphi Indy Components TCP File transfer ProgressBar question

Posted on 2007-03-27
4
8,364 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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

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…
Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

690 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