[omniORB] file transfer implementation code

Patrick Hubert hubert@discreet.com
Wed, 2 Jan 2002 22:13:52 -0500 (EST)



Hello again,

When I had to implement my iterators in my servers, I simply looked at
OmniORB's omniNames code (in directory omni/src/appl/omniNames/
files BindingIterator_i.h and NamingContext_i.cc) and euh... how shall I
put it nicely... "inspired" my new code from what I saw there.

Be aware that, as far as I understand the code I saw there, there is no
limitation on how many iterators can exist at a given time. Meaning that
if none of the clients ever calls destroy() on the iterators your server
might run out of ressources.

An optional implementation might keep a list of n active iterators, and
when the list is full and a new iterator is requested simply destroy the
oldest one. Clients should expect to receive a CORBA::OBJECT_NOT_EXIST if
they wait too long before using an iterator they've received.

Good luck.

 -Patrick

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

> Date: Wed, 2 Jan 2002 17:12:03 -0500 
> From: "Lanctot, Benoit" <benoit.lanctot@nrc.ca>
> To: "OmniORB Users' List (E-mail)" <omniorb-list@uk.research.att.com>
> Subject: RE: [omniORB] file transfer implementation code
> 
> 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
> 

--
Patrick Hubert
Work: +1.514.954.7233
Fax : +1.514.393.0110