#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Streams

Member Posts: 21
I'm using Client,server sockets to send large streams between my programs, how can I show the percent of the stream sent with a progressbar?

• Member Posts: 6,349
: I'm using Client,server sockets to send large streams between my programs, how can I show the percent of the stream sent with a progressbar?
:
You could first sent the stream size to the receiver. Then you start the stream and the receiver could keep track of the amount it has received. You can then easily calculate the percentage received.
• Member Posts: 21
: : I'm using Client,server sockets to send large streams between my programs, how can I show the percent of the stream sent with a progressbar?
: :
: You could first sent the stream size to the receiver. Then you start the stream and the receiver could keep track of the amount it has received. You can then easily calculate the percentage received.
:
I've done the first part, sending the size of the stream, but how do i work out how much has been received?
• Member Posts: 6,349
: : : I'm using Client,server sockets to send large streams between my programs, how can I show the percent of the stream sent with a progressbar?
: : :
: : You could first sent the stream size to the receiver. Then you start the stream and the receiver could keep track of the amount it has received. You can then easily calculate the percentage received.
: :
: I've done the first part, sending the size of the stream, but how do i work out how much has been received?
:
I'm not really sure, but try the size of the receiving stream (TStream.Size).
• Member Posts: 97
: : : I'm using Client,server sockets to send large streams between my programs, how can I show the percent of the stream sent with a progressbar?
: : :
: : You could first sent the stream size to the receiver. Then you start the stream and the receiver could keep track of the amount it has received. You can then easily calculate the percentage received.
: :
: I've done the first part, sending the size of the stream, but how do i work out how much has been received?
:

var
buf:array[0..2047] of byte;
x:integer;

progressbar.max:=streamsize;
stream2.write(buf,x);
progressbar.position:=stream2.size;

if you have a client/server the client (or server) would be stream1, stream2 would contain the real data. I don't use streams much, and I'm writing this from memory, not on a computer with delphi, so you may have to edit that a bit
• Member Posts: 59
: : : : I'm using Client,server sockets to send large streams between my programs, how can I show the percent of the stream sent with a progressbar?
: : : :
: : : You could first sent the stream size to the receiver. Then you start the stream and the receiver could keep track of the amount it has received. You can then easily calculate the percentage received.
: : :
: : I've done the first part, sending the size of the stream, but how do i work out how much has been received?
: :
:
: var
: buf:array[0..2047] of byte;
: x:integer;
:
: progressbar.max:=streamsize;
: stream2.write(buf,x);
: progressbar.position:=stream2.size;
:
: if you have a client/server the client (or server) would be stream1, stream2 would contain the real data. I don't use streams much, and I'm writing this from memory, not on a computer with delphi, so you may have to edit that a bit
:

or, you could use the position property of streams.
like Stream1.position.
another way might be to keep a 'ctr' variable, and initalize it to zero (0). then whenever data is read, consider: