1 ////////////////////////////////////////////////////////////////////////////// 2 // 3 // (C) Copyright Ion Gaztanaga 2006-2012. 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> 15 16 using namespace boost::interprocess; 17 main()18int main () 19 { 20 try{ 21 //Erase previous message queue 22 message_queue::remove("message_queue"); 23 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 30 ); 31 32 //Send 100 numbers 33 for(int i = 0; i < 100; ++i){ 34 mq.send(&i, sizeof(i), 0); 35 } 36 } 37 catch(interprocess_exception &ex){ 38 std::cout << ex.what() << std::endl; 39 return 1; 40 } 41 42 return 0; 43 } 44 //] 45 #include <boost/interprocess/detail/config_end.hpp> 46