消息队列
提供从一个进程向另一哥进程发送一块数据的方法
每个数据块都被认为有一个类型,接收者进程收到的数据块可以有不同类型值
消息队列的最大长度,总字节数,消息队列的数都有上限
comm.h
#pragma once
#include<stdio.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>
#include<string.h>
#define PATHNAME "."
#define PROJ_ID 0X6666
#define SERVER_TYPE 1
#define CLIENT_TYPE 2
struct msgbuf{ //消息结构
long mtype;
char mtext[1024];
};
int createMsgQueue(); //创建消息队列函数
int getMsgQueue(); //访问消息队列函数
int destroyMsgQueue(int msgid); //销毁消息队列函数
int sendMsg(int msgid, int who ,char *msg); //发送消息
int recvMsg(int msgid, int recvType, char out[]); //接受消息
comm.c