Howdy, Stranger!

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

Categories

Streams

KASKAS 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?

Comments

  • zibadianzibadian 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.
  • KASKAS 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?
  • zibadianzibadian 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).
  • neuronneuron 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;
    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 ;)
  • DhruvDhruv 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;
    : 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.
  • Justin BibJustin Bib USAMember Posts: 0

    ______ | http://forcoder.org | free ebooks and video tutorials about < MATLAB, PL/SQL, Delphi, Visual Basic .NET, Java, Assembly, Ruby, Perl, R, Objective-C, JavaScript, Visual Basic, C, PHP, C#, Swift, Python, Scratch, C++, Go SAS, Kotlin, Lua, LabVIEW, Alice, Scala, D, ML, F#, Prolog, Hack, Ada, Rust, VBScript, Erlang, Dart, Transact-SQL, ABAP, Logo, Bash, Fortran, Lisp, Clojure, FoxPro, COBOL, Apex, Scheme, Crystal, Julia, Awk /> ______________

Sign In or Register to comment.