吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1211|回复: 0
收起左侧

[C&C++ 转载] boost::interprocess::ipc::message_queue 问题探究一

[复制链接]
renaissancer 发表于 2022-3-29 20:35
记录一次使用boost的消息队列进行本机进程间通讯的问题:
1. 消息队列的名称 name 实际上就是共享内存的名字, 但是我是用 windows 下全局共享名字就会报错: 譬如:

[C++] 纯文本查看 复制代码
void MessageQueues::sendMsg(const char *name) {
    using namespace boost::interprocess;
    BOOST_TRY {
            //Erase previous message queue
            message_queue::remove(name);

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

            //Send 100 numbers
            for (int i = 0 ; i < 100 ; ++i) {
                mq.send(&i , sizeof(i) , 0);
            }
            std::cout << "send success !" << std::endl;
        } BOOST_CATCH(interprocess_exception &ex) {
            std::cout << ex.what() << std::endl;
            std::cout << ex.get_error_code() << std::endl;
            std::cout << ex.get_native_error() << std::endl;
        }BOOST_CATCH_END

}
其中: name 为 const char *name = "Global\\monika";


如此就会报错:
[C++] 纯文本查看 复制代码
The system cannot find the path specified.
7
3

问题1

问题1

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-16 21:04

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表