Archived

This forum has been archived. Please start a new discussion on GitHub.

How can I get the percentage of file transfer

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

  • benoit
    benoit Rennes, France
    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.
  • 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.
  • matthew
    matthew NL, Canada
    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.
  • Thank you very much!

    Thanks.Problem has already been resolved under your help.