#include <unistd.h>
#include <mqueue.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv)
{
mqd_t mqd;
void *ptr;
size_t len;
size_t prio;
if(argc != 4)
{
printf("usage: mqsend <name> <#bytes> <priority>");
}
len = atoi(argv[2]);
prio = atoi(argv[3]);
mqd = mq_open(argv[1], O_WRONLY);
ptr = calloc(len, sizeof(char));
mq_send(mqd, ptr, len, prio);
exit(0);
}
Posix消息队列的基本操作——发送消息
最新推荐文章于 2018-04-02 15:23:40 发布