Is it possible to build a concurrent interprocess message queue using boost?
<p>I am trying to build an application which have multiple processes. These processes need to write concurrently through the same message queue. At the other side, there will be just one process reading that queue.</p>

<p>Is that possible using boost? Or do I have to implement that mutual exclusion?</p>

<p>I took a look at the example source code but it is not working properly for my needs. I don't know if I'm missing something.</p>

<p>This is the code on the client:</p>

<pre><code>#include &lt;boost/interprocess/ipc/message_queue.hpp&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;unistd.h&gt;

using namespace boost::interprocess;

int main ()
{
   try{
      //Erase previous message queue
      //message_queue::remove("message_queue");

      //Create a message_queue.
      message_queue mq
         (open_or_create               //only create
         ,"message_queue"           //name
         ,100                       //max message number
         ,sizeof(int)               //max message size
         );

      //Send 100 numbers
      for(int i = 0; i &lt; 100; ++i){
         printf("Sending: %d\n", i);
         usleep(1000000);
         mq.send(&amp;i, sizeof(i), 0);
      }
   }
   catch(interprocess_exception &amp;ex){
      std::cout &lt;&lt; ex.what() &lt;&lt; std::endl;
      return 1;
   }

   return 0;
}
</code></pre>

<p>And server code:</p>

<pre><code>#include &lt;boost/interprocess/ipc/message_queue.hpp&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;

using namespace std;
using namespace boost::interprocess;

int main ()
{
   try{
      //message_queue::remove("message_queue");

      //Open a message queue.
      message_queue mq
         (open_only      //only create
         ,"message_queue"  //name
         );

      unsigned int priority;
      message_queue::size_type recvd_size;

      //Receive 100 numbers
      for(int i = 0; i &lt; 100; ++i){
         int number;
         mq.receive(&amp;number, sizeof(number), recvd_size, priority);
         if(number != i || recvd_size != sizeof(number))
            return 1;

         cout &lt;&lt; number &lt;&lt; endl;
      }
   }
   catch(interprocess_exception &amp;ex){
      message_queue::remove("message_queue");
      std::cout &lt;&lt; ex.what() &lt;&lt; std::endl;
      return 1;
   }
   //message_queue::remove("message_queue");
   return 0;
}
</code></pre>

<p>Thanks in advance.</p>