Search code examples
winapiwindows-mobilewindows-ceipcwindows-embedded

Broadcasting message to multiple processes (Point-to-Point Message Queue with multiple readers)


I want to share a data with multiple processes. My first attempt is to use Point to point message queue with multiple readers since I read that P2P Msg Queue is very fast.

During my test, it seems like multiple readers are reading from the same queue and once a message is fetched by one reader, other readers will not be able to fetch the same message.

What is a better IPC for sharing data to multiple processes? The data is updated frequently (multiple times per second) so I think WM_COPYDATA is not a good choice and will interfere with the "normal" message queue.

My second attempt will probably be a shared memory + mutex + events


Solution

  • Point-to-point queues will work fine. Yes, when you send, only one receiver will get the message but the sender can query the queue (by calling GetMsgQueueInfo) to see how many listeners (wNumReaders member of the MSGQUEUEINFO) there are and simply repeat the message that number of times.