[omniORB] Exception while sending an octet sequence

Ali Reza A.Reza at zensar.com
Fri Nov 21 18:46:15 GMT 2003


Hi!
I tried analyzing the mistake I made but apparently I could not find any reason why 
  BinaryFile_var image_seq = new BinaryFile(stat_values.st_size);
should work....and 
  BinaryFile *image_seq = new BinaryFile(stat_values.st_size);
should not work ? 
  I agree that usage of a smart pointer is a better practice ? But in my case the program was crashing when 
I returned return image_seq; instead of return image_seq._retn(); 

Could somebody explain - why ?

-----Original Message-----
From: baileyk at schneider.com [mailto:baileyk at schneider.com]
Sent: Wednesday, November 19, 2003 9:58 PM
To: Ali Reza
Cc: omniORB Submissions (E-mail)
Subject: Re: [omniORB] Exception while sending an octet sequence



Note some fixes on these lines

  image_oct_buf = new CORBA::Octet[stat_values.st_size]; // you need square
brackets
  BinaryFile_var image_seq = new BinaryFile(stat_values.st_size); // _var
is safer
  image_seq->length( stat_values.st_size ); // still need to set the length

...
    image_seq[i] = *(image_oct_buf + i); // _var type has convenient
operator[]

...
  return image_seq._retn();

Hope this helps.

Kendall




                                                                                                                                  
                      "Ali Reza"                                                                                                  
                      <A.Reza at zensar.com>                  To:       "omniORB Submissions (E-mail)"                               
                      Sent by:                              <omniorb-list at omniorb-support.com>                                    
                      omniorb-list-bounces at omniorb-        cc:                                                                    
                      support.com                          Fax to:                                                                
                                                           Subject:  [omniORB] Exception while sending an octet sequence          
                                                                                                                                  
                      11/19/2003 09:15 AM                                                                                         
                                                                                                                                  
                                                                                                                                  




I have encountered the following exception while trying to use an octet
sequence....

CORBA System ExceptionIDL:omg.org/CORBA/UNKNOWN:1.0
Completion status 2
Minor 1330446337
Meaningful name for minor code UNKNOWN_UserException

My servant code is...

BinaryFile* TS::BinaryFileExchange_impl::fetch(const char* file_name)
{
  int file_handle = open(file_name,_A_RDONLY);
  struct stat stat_values;
  fstat(file_handle,&stat_values);
  CORBA::Octet *image_oct_buf;
  image_oct_buf = new CORBA::Octet(stat_values.st_size);
  BinaryFile *image_seq = new BinaryFile(stat_values.st_size);
  image_seq->length(stat_values.st_size);


  read(file_handle,image_oct_buf,stat_values.st_size);
  for (int i = 0; i < stat_values.st_size ; ++i) {
    *(image_seq + i) = *(image_oct_buf + i);
  }
  delete [] image_oct_buf;
  close(file_handle);

  return image_seq
}

// My IDL is ...
  typedef sequence<octet> BinaryFile;
  interface BinaryFileExchange {
    void send(in BinaryFile f, in string file_name);
    BinaryFile fetch(in string file_name);
  };

Could somebody explain whats happening ? Where things are going wrong ??
on   cout <<  "Length of image_seq" << image_seq->length() << endl;
I get a proper sized sequence i.e. the size of the number of bytes of ,y
gif file.

Thx./Ali

_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list








More information about the omniORB-list mailing list