[omniORB] file transfer implementation code

Lanctot, Benoit benoit.lanctot@nrc.ca
Wed, 2 Jan 2002 17:12:03 -0500


Thanks a lot Patrick and Bjorn,

Now I do understand how to transfer a file, but I really need to use an
Iterators.

In Henning/Vinosky they show a example of a client code (18.7.2, p 801-802)
but I've got no Idea how to write the server implementation that would use
an Iterators.

Could someone show me a implementation example of an Iterators? It would be
very appreciated!

Thanks again


Ben

-----Original Message-----
Subject: Re: [omniORB] file transfer implementation code

Hi

I'm also a CORBA beginner, so my first recommendation would be to have a
look at "Advanced CORBA Programming with C++" by Henning/Vinosky (an
excellent book to own) at page 187 to 194. They give an example of
transfering a GIF image file from a server to a client.

Seeing that you use an iterator, I guess that you are aware that there is
a maximum size to each GIOP message (which is 2Megs with OmniOrb I
believe). I obviously do not know all the details of what you are trying
to achieve, but using CORBA to transfer huge ammount of raw data is far
from optimal. Using sockets might yield faster transfer rates.

In the book, the example uses a "sequence<octet>" instead of
"sequence<char>" as you are doing... I'm not sure if it changes anything.


On the server side, you want to do something like:

// assuming that you already have a buffer named dataBuffer filled with
// your data and dataSize is the number of bytes in that buffer. Make
// sure that dataSize < omniORB::MaxMessageSize()

FileChunk_var chunk = new FileChunk();
chunk->length( dataSize );

memcpy( chunk->get_buffer(), dataBuffer, dataSize );

delete [] dataBuffer; // unless you want to keep it around of course.

return chunk._retn();


That's a very simple and non-optimized example. Look at p. 188-189 for
something more efficient.


Good luck.


 -Patrick


On Wed, 2 Jan 2002, Lanctot, Benoit wrote:

> Date: Wed, 2 Jan 2002 14:17:05 -0500 
> From: "Lanctot, Benoit" <benoit.lanctot@nrc.ca>
> To: "OmniORB Users' List (E-mail)" <omniorb-list@uk.research.att.com>
> Subject: [omniORB] file transfer implementation code
> 
> Hi everyone,
> 
> I am trying to transfer large (5 to 100 Meg) ASCII file using CORBA.  I
have
> an idl example:
> 
> 
> typedef sequence<char> FileChunk;
> typedef unsigned short ChunkSize;
> 
> interface FileIterator {
>    FileChunk next(in ChunkSize how_much);
>    void destroy();
> };
> 
> interface FileTransfert {
>    FileChunk get(in string fname, in ChunkSize how_much, out FileIterator
> ft);
>    void put(in string fname, in FileChunk first, in FileIterator ft);
> };
> 
> 
> I am CORBA beginner; I don't understand how to write the implementation
code
> for the server?
> 
> Couldn't someone help me?
> 
> Thanks
> 
> 
> Ben
> 
> Benoit Lanctot
> Intelligent Forming Technologies
> Industrial Materials Institute / National Research Council Canada
> Boucherville, Quebec, Canada
> 
--
Patrick Hubert
Work: +1.514.954.7233
Fax : +1.514.393.0110