How can I develop a File transfer application?question 1

xiehuaxiehua Member ✭✭
question 1 ,how can I transfer a file via Ice?
A file may be text file,picture file,or other binary file.
I look up the Ice pdf.But have no idea of how to transfer them.
The Basic Slice Type I can use is "byte",maybe I should slice
the file into "byte" data and transfer it?Is there any better way?
can you tell me the main point?


---development platform
vc 7.1
win2000 professional simplified chinese
ice 1.20

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    You can have a look at the implementation of icepatch, which is transferring files. (In src/Icepatch.)
  • xiehuaxiehua Member ✭✭
    thank you,I go to look at it.
  • amrufonamrufon Member AlexOrganization: ISTProject: jDatabase ✭✭
    Hey xiehua,

    I've successfully implemented something similar to this using an earlier version of ICE.

    What I did was create a SLICE definition similar to this:
    sequence<byte> ByteSeq;
    interface jfilesystem
    {
    bool jfsUpload(ByteSeq data);
    };

    I then created a server which would create a sequencially named file everytime the jfsUpload method is invoked. The server writes the passed parameter to the file. The client just opens the file as binary and pass its contents as parameter to the method. Works like a charm. ;)

    There a catch though, the older version of ICE only supports up to 1MB of data to be transfered per request. Since I was transfering data in the 8MB range per call, I asked for tech support and Marc Laukien was kind enough to point me in the right direction:
    At present we have a hard limit of 1MB in Ice as the maximum request size.
    For the next version, you will be able to change this size with a property.
    With the current version, you have to change the Ice code. In
    src/Ice/BasicStream.cpp, there are two lines that look as follows:


    if(total > 1024 * 1024) // TODO: configurable.


    Change this to:


    if(total > 10 * 1024 * 1024) // TODO: configurable.


    To raise the limit to 10MB per request. (Or any other value you like.)

    Cheers,
    Marc

    I haven't tested if ZeroC have implemented the property mentioned above in ICE 1.2 since the sample code was used in our prototype and were currently in design stage for the actual project.

    Hope this helps.

    Alex
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    There is now a property for the maximum message size. Just set Ice.MessageSizeMax (in KB) to the desired maximum. See the Ice documentation for details (the Appendix with the description of all properties).

    If the files are very large, it might still make sense to transfer them in chunks of data, like IcePatch does.
  • ganzuoniganzuoni Member Guido AnzuoniOrganization: IndividualProject: No specific project ✭✭
    Hi,
    I have used a classical stream approach with the following definition:

    module io {
    sequence<byte> IOBuffer;

    exception IOException {
    string message;
    };
    exception EOFException extends IOException {
    };



    interface StreamSink {
    void write(IOBuffer bytes) throws IOException;
    void close() throws IOException;
    };
    interface StreamSource {
    IOBuffer read(long nbytes) throws IOException;
    void close() throws IOException;
    };

    interface RemoteDir {
    StreamSource *open(string name) throws IOException;
    };
    };

    Using 64Kb buffer it's rather fast and gives no troubles on max message size.
    It is also trivial to write a Java InputStream adapter for a StreamSource and
    an OutputStream for a StreamSink so you can, for example, unzip
    a remote file....


    Regards,
    Guido.
  • xiehuaxiehua Member ✭✭
    thank you,marc
    thank you,Alex
    thank you,Guido

    you are so kind!!!

    A good news is that My application of file transfer can work with your help!

    now I try to make it better.
  • catalincatalin Member ✭✭
    Where is Icepatch documented?

    Hi!

    It is a while now since I read the Ice documentation, and I can not remember where Icepatch is documented. It isn't listed in the table of contents either (or am I blind?).

    Is Icepatch an API for transfering files, or it just happens that in doing whatever Icepatch does, it needs to transfer files so it implements an example of how to do it?

    If it is an API for file transfer, is it configurable, like choosing which protocol to use (I guess UDP, TCP/IP and SSH are available), the size of the packets to send, setting timers and so on.

    Thanks,
    Catalin
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Sorry, we still don't have an IcePatch documentation (except for the properties).

    IcePatch is really three things:
    • A server, that compresses files and can send them to multiple clients. ("icepatchserver")
    • A library that allows you to build your own client.
    • A sample client. ("icepatchclient")

    For an example on how to use icepatchserver and icepatch client, see:

    http://www.zeroc.com/vbulletin/showthread.php?threadid=254
  • catalincatalin Member ✭✭
    Hi!

    It seems to me then that IcePatch is a kind of file synchronization mechanism. What was the motivation behind it?

    I can also see that it is implemented by quite a voluminous amount of code, IcePatch.cpp alone amounts to something like 2643 lines.

    Can I turn off the compression mechanism? If a file is already compressed, say a JPEG picture, it won't compress any significant more by running it again through a compression mechanism. If I am wrong about JPEG pictures I guess I still am right about an already compressed .gz file.

    Can you tell more about the library which can be used to build own clients? Which features does it have?

    Thanks
    Catalin
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Originally posted by catalin
    Hi!

    It seems to me then that IcePatch is a kind of file synchronization mechanism. What was the motivation behind it?

    It is used for patching software products. For example, Mutable Realms uses IcePatch for their game client: If a user connects to the game server, the game client is first updated with the latest patches.
    Originally posted by catalin
    I can also see that it is implemented by quite a voluminous amount of code, IcePatch.cpp alone amounts to something like 2643 lines.

    Well, it also does a lot of stuff. If all you want is a simple point-to-point file transfer, then IcePatch is an overkill.
    Originally posted by catalin
    Can I turn off the compression mechanism? If a file is already compressed, say a JPEG picture, it won't compress any significant more by running it again through a compression mechanism. If I am wrong about JPEG pictures I guess I still am right about an already compressed .gz file.

    Not without changing the code.
    Originally posted by catalin
    Can you tell more about the library which can be used to build own clients? Which features does it have?

    It's bascially a set of utility functions that check MD5 files, uncompress, get files from the IcePatch server, show download progress using callbacks, etc. Have a look at Client.cpp for how the library can be used.
  • alesioalesio Member
    Hello,
    I am studying the IcePatch .I can built the IcePatch server source code in ICE-1.2.0\src\IcePatch. But I have a problem when i run it. It appear a memory error dialog.why?How can solute it? Thank you!!!
Sign In or Register to comment.