【问题标题】:Problems with boost.interprocess for bidirectional messaging using message_queue使用 message_queue 进行双向消息传递的 boost.interprocess 问题
【发布时间】: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


    【解决方案1】:

    我没有收到任何关于此的 cmets。解决方案是不使用 boost::interprocess::message_queue。在 boost/interprocess/shared_memory_object 的帮助下,我自己编写了一个新的、简单的用于单向进程间消息传递的库。 https://github.com/svebert/InterprocessMsg

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-04
      • 2016-09-17
      • 2020-01-23
      • 2018-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-05
      相关资源
      最近更新 更多