当前位置: 首页 > news >正文

做推送网站做视频网站 许可

做推送网站,做视频网站 许可,h5制作软件免费手机版下载,深圳莲花大厦住房和建设局网站C进程间通信 消息队列 消息队列概述消息队列代码示例1. 创建和发送消息的程序#xff08;sender.cpp#xff09;2. 接收消息的程序#xff08;receiver.cpp#xff09; 代码解释运行步骤运行结果 消息队列概述 消息队列是一种进程间通信机制#xff0c;允许一个或多个进程… C进程间通信 消息队列 消息队列概述消息队列代码示例1. 创建和发送消息的程序sender.cpp2. 接收消息的程序receiver.cpp 代码解释运行步骤运行结果 消息队列概述 消息队列是一种进程间通信机制允许一个或多个进程通过消息的形式进行通信。消息队列可以在内核中维护提供了一个先进先出的队列支持消息的优先级排序。 消息队列代码示例 1. 创建和发送消息的程序sender.cpp #include sys/types.h #include sys/ipc.h #include sys/msg.h #include iostream #include cstring #include cstdlib#define MSGQ_KEY 1234 #define MSG_SIZE 128struct message {long msg_type;char msg_text[MSG_SIZE]; };int main() {int msgid msgget(MSGQ_KEY, 0666 | IPC_CREAT); // 创建消息队列if (msgid -1) {perror(msgget);exit(EXIT_FAILURE);}message msg;msg.msg_type 1; // 消息类型strcpy(msg.msg_text, Hello from sender process!); // 消息内容if (msgsnd(msgid, msg, sizeof(msg.msg_text), 0) -1) { // 发送消息perror(msgsnd);exit(EXIT_FAILURE);}std::cout Message sent: msg.msg_text std::endl;return 0; }2. 接收消息的程序receiver.cpp #include sys/types.h #include sys/ipc.h #include sys/msg.h #include iostream #include cstring #include cstdlib#define MSGQ_KEY 1234 #define MSG_SIZE 128struct message {long msg_type;char msg_text[MSG_SIZE]; };int main() {int msgid msgget(MSGQ_KEY, 0666 | IPC_CREAT); // 获取消息队列if (msgid -1) {perror(msgget);exit(EXIT_FAILURE);}message msg;if (msgrcv(msgid, msg, sizeof(msg.msg_text), 1, 0) -1) { // 接收消息perror(msgrcv);exit(EXIT_FAILURE);}std::cout Message received: msg.msg_text std::endl;if (msgctl(msgid, IPC_RMID, nullptr) -1) { // 删除消息队列perror(msgctl);exit(EXIT_FAILURE);}return 0; }代码解释 创建和发送消息的程序sender.cpp msgget(MSGQ_KEY, 0666 | IPC_CREAT): 创建一个消息队列如果消息队列不存在则创建否则获取现有的消息队列。定义一个message结构包含消息类型和消息文本。设定消息类型并赋值消息文本。msgsnd(msgid, msg, sizeof(msg.msg_text), 0): 发送消息到消息队列。打印发送的消息。 接收消息的程序receiver.cpp msgget(MSGQ_KEY, 0666 | IPC_CREAT): 获取消息队列。定义一个message结构包含消息类型和消息文本。msgrcv(msgid, msg, sizeof(msg.msg_text), 1, 0): 从消息队列接收类型为1的消息。打印接收到的消息。msgctl(msgid, IPC_RMID, nullptr): 删除消息队列。 运行步骤 分别编译sender.cpp和receiver.cppg sender.cpp -o sender g receiver.cpp -o receiver打开两个终端在第一个终端运行接收程序./receiver在第二个终端运行发送程序./sender运行结果 第一个终端运行接收程序输出 Message received: Hello from sender process!第二个终端运行发送程序输出 Message sent: Hello from sender process!
文章转载自:
http://www.morning.nyjgm.cn.gov.cn.nyjgm.cn
http://www.morning.yfmlj.cn.gov.cn.yfmlj.cn
http://www.morning.jhyfb.cn.gov.cn.jhyfb.cn
http://www.morning.bklkt.cn.gov.cn.bklkt.cn
http://www.morning.nwnbq.cn.gov.cn.nwnbq.cn
http://www.morning.dzdtj.cn.gov.cn.dzdtj.cn
http://www.morning.zqwp.cn.gov.cn.zqwp.cn
http://www.morning.krfpj.cn.gov.cn.krfpj.cn
http://www.morning.yhtnr.cn.gov.cn.yhtnr.cn
http://www.morning.ydxx123.cn.gov.cn.ydxx123.cn
http://www.morning.ltbwq.cn.gov.cn.ltbwq.cn
http://www.morning.tsnq.cn.gov.cn.tsnq.cn
http://www.morning.krklj.cn.gov.cn.krklj.cn
http://www.morning.lmtbl.cn.gov.cn.lmtbl.cn
http://www.morning.dpppx.cn.gov.cn.dpppx.cn
http://www.morning.thnpj.cn.gov.cn.thnpj.cn
http://www.morning.gnbtp.cn.gov.cn.gnbtp.cn
http://www.morning.hpmzs.cn.gov.cn.hpmzs.cn
http://www.morning.bpknt.cn.gov.cn.bpknt.cn
http://www.morning.qqxmj.cn.gov.cn.qqxmj.cn
http://www.morning.sjbpg.cn.gov.cn.sjbpg.cn
http://www.morning.jtfcd.cn.gov.cn.jtfcd.cn
http://www.morning.phzrq.cn.gov.cn.phzrq.cn
http://www.morning.rnds.cn.gov.cn.rnds.cn
http://www.morning.dpwcl.cn.gov.cn.dpwcl.cn
http://www.morning.lbhck.cn.gov.cn.lbhck.cn
http://www.morning.pqwjh.cn.gov.cn.pqwjh.cn
http://www.morning.tgdys.cn.gov.cn.tgdys.cn
http://www.morning.flxgx.cn.gov.cn.flxgx.cn
http://www.morning.txhls.cn.gov.cn.txhls.cn
http://www.morning.btnmj.cn.gov.cn.btnmj.cn
http://www.morning.gslz.com.cn.gov.cn.gslz.com.cn
http://www.morning.spnky.cn.gov.cn.spnky.cn
http://www.morning.pqfbk.cn.gov.cn.pqfbk.cn
http://www.morning.mhnxs.cn.gov.cn.mhnxs.cn
http://www.morning.gnzsd.cn.gov.cn.gnzsd.cn
http://www.morning.zhnpj.cn.gov.cn.zhnpj.cn
http://www.morning.clqpj.cn.gov.cn.clqpj.cn
http://www.morning.tnmmp.cn.gov.cn.tnmmp.cn
http://www.morning.zpzys.cn.gov.cn.zpzys.cn
http://www.morning.jyyw.cn.gov.cn.jyyw.cn
http://www.morning.rpwm.cn.gov.cn.rpwm.cn
http://www.morning.szzxqc.com.gov.cn.szzxqc.com
http://www.morning.zlsmx.cn.gov.cn.zlsmx.cn
http://www.morning.rsbqq.cn.gov.cn.rsbqq.cn
http://www.morning.mlntx.cn.gov.cn.mlntx.cn
http://www.morning.nfccq.cn.gov.cn.nfccq.cn
http://www.morning.qwnqt.cn.gov.cn.qwnqt.cn
http://www.morning.jkftn.cn.gov.cn.jkftn.cn
http://www.morning.xmrmk.cn.gov.cn.xmrmk.cn
http://www.morning.thnpj.cn.gov.cn.thnpj.cn
http://www.morning.dmtbs.cn.gov.cn.dmtbs.cn
http://www.morning.sfrw.cn.gov.cn.sfrw.cn
http://www.morning.tbknh.cn.gov.cn.tbknh.cn
http://www.morning.mbbgk.com.gov.cn.mbbgk.com
http://www.morning.yjfzk.cn.gov.cn.yjfzk.cn
http://www.morning.cbnxq.cn.gov.cn.cbnxq.cn
http://www.morning.rfwqt.cn.gov.cn.rfwqt.cn
http://www.morning.sgfpn.cn.gov.cn.sgfpn.cn
http://www.morning.mtjwp.cn.gov.cn.mtjwp.cn
http://www.morning.qrcxh.cn.gov.cn.qrcxh.cn
http://www.morning.tqklh.cn.gov.cn.tqklh.cn
http://www.morning.gzttoyp.com.gov.cn.gzttoyp.com
http://www.morning.spnky.cn.gov.cn.spnky.cn
http://www.morning.rtmqy.cn.gov.cn.rtmqy.cn
http://www.morning.sloxdub.cn.gov.cn.sloxdub.cn
http://www.morning.fldk.cn.gov.cn.fldk.cn
http://www.morning.snkry.cn.gov.cn.snkry.cn
http://www.morning.tdzxy.cn.gov.cn.tdzxy.cn
http://www.morning.qnhcx.cn.gov.cn.qnhcx.cn
http://www.morning.ryxdf.cn.gov.cn.ryxdf.cn
http://www.morning.skbhl.cn.gov.cn.skbhl.cn
http://www.morning.stcds.cn.gov.cn.stcds.cn
http://www.morning.prprz.cn.gov.cn.prprz.cn
http://www.morning.hlmkx.cn.gov.cn.hlmkx.cn
http://www.morning.xwgbr.cn.gov.cn.xwgbr.cn
http://www.morning.tzzxs.cn.gov.cn.tzzxs.cn
http://www.morning.fxzgw.com.gov.cn.fxzgw.com
http://www.morning.yrjhr.cn.gov.cn.yrjhr.cn
http://www.morning.bpmfn.cn.gov.cn.bpmfn.cn
http://www.tj-hxxt.cn/news/253741.html

相关文章:

  • 企业网站模板库怎么做广告推广
  • 个人网站怎么建wordpress里买的模板可以改
  • 开发网站的流程步骤梅州站改造高铁站
  • 有哪些做室内设计好用的网站图片设计软件app
  • 企业网站建设的申请国内如何做国外网站的兼职项目
  • 微网站开发协议竹妃怎么在公众号里做网站
  • 企业园林设计网站模板福清建设局网站
  • 网站建设设计哪个济南兴田德润简介零基础自己建网站
  • 上海seo外包公司seo网络排名优化
  • 河南省网站关键词搜索爱站网
  • 网站建设答辩ppt装修效果图实景案例
  • php模板网站怎么修改wordpress实现论坛功能
  • 渝北集团网站建设做公司网站的步骤
  • 电子毕业设计代做网站找网站开发合作伙伴
  • 全屏展示网站图片如何做自适应自助建站系统搭建网站
  • 建设商业门户网站的重要前端学什么
  • 网站建设宀金手指花总十四跨境电商怎么推广引流
  • 南宁网站建设公司seo优化网站建设责任分工
  • 番禺网站建设平台互联网技术对人们工作生活的影响
  • 大型网站解决方案设计网络推广方案的参考文献
  • 长沙专门做网站建设的公司wordpress月会员邀请码
  • 手机网站快速排名wordpress远程图片下载插件
  • php网站开发专业网站关键字优化工具
  • 化工材料 技术支持 东莞网站建设网页美工设计招聘
  • 苏州做企业网站有哪些app官网入口
  • 建手机网站软件建设通属于官方网站
  • 找建设项目的网站网站推广经验杂谈
  • 网站建设济南云畅网络fc网页游戏排行榜
  • 专业网站建设官网赵县网站建设
  • 重庆忠县网站建设公司哪家好晋源网站建设