Home Help Center

How can I get the percentage of file transfer

fengshenghelifengshengheli Member zhang mqOrganization: sddlProject: substation
I write the slice like this:

bool getFile(string filename);

The server get the file from a remote machine and return true or false when transfering completed. I don't know how to send messages to the client when transfering.

How can I get the percentage of file transfer when the client invoking this function? Can you help me?

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    You might be able to use the Ice::Stats interface for this purpose. See here in the Ice manual for more information.

    Cheers,
    Benoit.
  • fengshenghelifengshengheli Member zhang mqOrganization: sddlProject: substation
    I try to use Ice::Stats,but I dont' think it works well.

    Thanks for your help! I write a client and a server using Ice::Stats.I found that the Ice::Stats only get the bytes sent and recevied between client and server.But it does not meet my requirement.There are my client and server in the accessories.
    My develop environment:winxpsp2 vc2005 Ice3.3.0

    In my project,clients and server works like this:
    1、The client invokes function getFile, and this returns true or false.True means the server get the file from the other computer success,false means some error occurs.
    2、The server get the file by socket or by seriport,and send percentage to client.Return true or false at the end.(The problem is how to send messages to the client and how to receive messages from the server.)
    3、The client doesn't get the file from the server in fact,but only needs to get informations the server happenning.

    My English is poor,so I don't know if you understand what I mean.Thanks.
  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    I would use some callback interface to do this. You could do something like this:
    interface TransferFileCallback
    {
        void transferred(float f); // Percentage transferred between 0 and 1.
        void failed(string reason); // Transfer failed.
    };
    
    interface TransferFile
    {
       // Returns true if the file will be transferred, false otherwise.
       bool getFile(string filename, PercentageCallback* cb);
    };
    

    If you want to use Ice to transfer the files themselves, you might also want to read my article "Optimizing Performance of File Transfers" in http://www.zeroc.com/newsletter/issue20.pdf.
  • fengshenghelifengshengheli Member zhang mqOrganization: sddlProject: substation
    Thank you very much!

    Thanks.Problem has already been resolved under your help.
Sign In or Register to comment.