Hi,

I forgot to mention that the exception was from the receive( ) method.

Thanks & Regards,
Rohini Chandra P

---------- Forwarded message ----------
From: rohini chandra pallapothu <rohinichandrap@gmail.com>
Date: Mon, Nov 29, 2010 at 7:14 PM
Subject: boost::interprocess_exception::library_error
To: boost-users@lists.boost.org


Hi,
 
I am trying to use boost message queues for interprocess communincation between a command and a server.  I had been receiving the below exception in the server.
 
boost::interprocess_exception::library_error
 
Below is the server code I had problems with. The exception was consistent when the maximum message size argument of the method was greater than the size of the data I was trying to send.
I am trying to send an integer. When I assigned the max_msg_size variable a size greater than the size of int, it threw an exception. When I assigned the size of int, it is working fine. I got this working
just before I was about to send this mail. But I want to understand the correct reason behind the exception. Is it not allowed to send a message which is less than the maximum message size because the name maximum message size itself says that it should only not exceed. I am working on a 64 bit SUSE 11. I am new to boost and Linux. I had even tried to change the /proc/sys/kernel/shmmax value after reading one of the discussion on the same exception in the BOOST archives which did not work. Could anyone please help. Please let me know if you need more information.
 
std::size_t   max_msg_size=sizeof(int);
 
 
============testsvc=================
 
#include <boost/interprocess/sync/named_mutex.hpp>
#include <boost/interprocess/ipc/message_queue.hpp>
#include <iostream>
using namespace std;
using namespace boost::interprocess;

int main(){ 
   cout<<"in main"<<endl;
   cout<<"size of int is "<<sizeof(int)<<endl; //4 on my platform
  
   unsigned int                priority;
   std::size_t                 recvd_size;
   std::size_t                 max_msg_size=sizeof(int); //not working when assigned a larger value than I was sending.
   std::size_t                 max_no_msgs=10;
   int i;
  
   message_queue::remove("TestQueue");
   cout<<"message queue removed if any"<<endl;
   try{
   //create a message queue.
   message_queue mq(create_only,"TestQueue",max_no_msgs,max_msg_size);
   cout<<"message queue created"<<endl;
  
   mq.receive(&i,sizeof(i),recvd_size,priority);
   }
   catch(interprocess_exception &ex){
   std::cout <<ex.what() << std::endl;
   return 1;
   }
   cout<<"message received"<<endl;
   cout<<"message received is"<<i<<endl;
   return 0;
}
====================
 
Thanks in advance.
 
Best Regards,
Rohini Chandra