【发布时间】:2019-01-08 20:31:39
【问题描述】:
我正在尝试使用 boost.interprocess 和 message_queue 在两个进程之间实现消息传递系统。
第一个问题:一个队列只能用于从进程A向B发送消息,不能从B向A发送消息。
因此,我在两个进程中都使用了两个队列。进程 A 在 Queue-A 上侦听/接收,并在 Queue-B 上发送;进程 B 在 Queue-B 上侦听/接收,并在 Queue-A 上发送。
我无法让 to 系统与两个队列一起工作。取决于调用boost::interprocess::message_queue(boost::interprocess::open_or_create,...) 的进程的顺序
或
boost::interprocess::message_queue(boost::interprocess::open_only,...)
一个队列工作或另一个或都不工作。
即使进程 A 创建 Queue-A 和 Queue-B 并且进程 B 仅打开 Queue-A 和 Queue-B。在一个方向 boost::interprocess 卡在接收函数上并且永远不会醒来。
1) 是否有可能在每个进程中使用两个队列让双向消息传递/信令与 interprocess::message_queue 一起使用? 2) 有没有更好的方法在不使用 message_queue 的情况下获得双向消息?
【问题讨论】:
标签: linux windows c++11 boost message-queue