Release 1.39.0
[boost.git] / Boost_1_39_0 / libs / interprocess / example / comp_doc_message_queueA.cpp
blob04c18389cec35c522eaafca1428e6064becb2738
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2006-2007. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10 #include <boost/interprocess/detail/config_begin.hpp>
11 //[doc_message_queueA
12 #include <boost/interprocess/ipc/message_queue.hpp>
13 #include <iostream>
14 #include <vector>
16 using namespace boost::interprocess;
18 int main ()
20 try{
21 //Erase previous message queue
22 message_queue::remove("message_queue");
24 //Create a message_queue.
25 message_queue mq
26 (create_only //only create
27 ,"message_queue" //name
28 ,100 //max message number
29 ,sizeof(int) //max message size
32 //Send 100 numbers
33 for(int i = 0; i < 100; ++i){
34 mq.send(&i, sizeof(i), 0);
37 catch(interprocess_exception &ex){
38 std::cout << ex.what() << std::endl;
39 return 1;
42 return 0;
44 //]
45 #include <boost/interprocess/detail/config_end.hpp>