Solved

Delphi Indy Components TCP File transfer ProgressBar question

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VPN 101 - how and which protocol? 9 111
Eclipse. How to move up/down source folders 4 89
Change local server setting in php 6 90
I could not build boost code, 10 90
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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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 use and create keystrokes in Netbeans IDE 8.0 for Windows.

825 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