发送信息的法度榜样的源文件msgsend.c的源代码为:
- #include <unistd.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <sys/msg.h>
- #include <errno.h>
- #define MAX_TEXT 512
- struct msg_st
- {
- long int msg_type;
- char text[MAX_TEXT];
- };
- int main()
- {
- int running = 1;
- struct msg_st data;
- char buffer[BUFSIZ];
- int msgid = -1;
- //建立消息队列
- msgid = msgget((key_t)1234, 0666 | IPC_CREAT);
- if(msgid == -1)
- {
- fprintf(stderr, "msgget failed with error: %d\n", errno);
- exit(EXIT_FAILURE);
推荐阅读
Windows 10 Build 16215带来的11大Fall Creators Update最佳功能_IT技术周刊第506期
【义务编辑:刘晶晶 TEL:(010)68476606】 >>>详细阅读
本文标题:Linux进程间通信——使用消息队列
地址:http://www.17bianji.com/lsqh/35826.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示