Streams

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?

Comments

  • : 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'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 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).
  • : : : 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;
    x:=stream1.read(buf,2048);
    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 ;)
  • : : : : 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;
    : x:=stream1.read(buf,2048);
    : 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:
    x := StreamX.Read (buf, 1024);
    Inc (ctr, x);
    then , ctr would give you the number of bytes read.
Sign In or Register to comment.

Howdy, Stranger!

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

Categories