[omniORB] Octet type
Huw Rogers
count0@building2.co.jp
Thu, 29 Mar 2001 15:07:22 +0900
This is way inefficient. You can directly
access &(*errors)[0] to get the start
of the 2000 byte buffer, and fill it directly
with one read, then set the length. No
need for a loop.
-Huw
Brecht Vermeulen wrote:
> Michel,
>
> this code does this (bytestream is a sequence of octets) :
>
>
> click_router::bytestream_var errors = new click_router::bytestream;
>
>
> // now read the errors and return them
> ifstream errors_file(CLICK_ERRORS);
> errors->length(2000); // start length of 2000 octets
>
> CORBA::Octet ch;
> CORBA::ULong i=0;
> while(errors_file.get(ch) ) {
> if (i>errors->length()-1) errors->length(i+500);
> errors[i++] = ch;
> };
>
> errors->length(i);
>
> errors_file.close();
>
> return errors._retn();
>
> best regards,
> Brecht
>
> Miguel wrote:
> >
> > Hi
> >
> > I have to transmit a texture from a server to a client. It can be in
> > different formats (such as .rgb, .jpg, .gif...) so I've decided to
> > send all of them as a sequence of octets. The problem is that I don't have
> > a good knowledge about using the octet type, so
> > I don't know how to read data from the file and convert it to an octet (and
> > how to convert an octet to data) (perhaps with
> > a simple cast??)
> >
> > Any suggestion or info about the octet type?
> >
> > Thank you very much.
> >
> > Bye.