I am using boost::interprocess::message_queue and as per the definition given on http://www.boost.org/doc/libs/1_35_0/doc/html/boost/interprocess/message_queue.html
message_queue(open_only_t open_only, const char * name);
now what i can't understand is that how a constructor is returning a value? though it states " the function returns false" but afaik message_queue is supposed to be a constructor.
and also if it do return false can i catch that in a Boolean variable?
A boost::interprocess::interprocess_exception will be thrown instead, as the current documentation suggests.
So,
using namespace boost::interprocess;
try {
//Create a message_queue. If the queue
//exists throws an exception
message_queue mq
(create_only //only create
,"message_queue" //name
,100 //max message number
,100 //max message size
);
} catch (interprocess_exception const& ipe)
{
std::cerr << "Error: #" << ipe.get_error_code() << ", " << ipe.what() << "\n";
}
When run twice, will print
Error: #9, File exists
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With