当前位置: 技术问答>linux和unix
mq_open消息队列的问题。
来源: 互联网 发布时间:2015-08-02
本文导语: 利用mq_open创建消息队列,每次返回的errno = 22:Invalid argument 为什么呢?编译都通过了! 代码如下: struct mq_attr _MsgQueueAttr; memset((void *)&_MsgQueueAttr, 0, sizeof(struct mq_attr)); _MsgQueueAttr.mq_flags = O...
利用mq_open创建消息队列,每次返回的errno = 22:Invalid argument 为什么呢?编译都通过了!
代码如下:
struct mq_attr _MsgQueueAttr;
memset((void *)&_MsgQueueAttr, 0, sizeof(struct mq_attr));
_MsgQueueAttr.mq_flags = O_NONBLOCK;
_MsgQueueAttr.mq_maxmsg = MAX_MESSAGE_COUNT;
_MsgQueueAttr.mq_msgsize = MAX_MESSAGE_LENGTH;
mqd_t _hMessageQueue = MESSAGE_QUEUE_ERROR;
_hMessageQueue = mq_open("temp.1234",
O_CREAT | O_RDWR | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
NULL);
if( MESSAGE_QUEUE_ERROR == _hMessageQueue)
{
printf("create queue failed.nr");
printf("%d", errno);
return -1;
}
mq_close(_hMessageQueue);
代码如下:
struct mq_attr _MsgQueueAttr;
memset((void *)&_MsgQueueAttr, 0, sizeof(struct mq_attr));
_MsgQueueAttr.mq_flags = O_NONBLOCK;
_MsgQueueAttr.mq_maxmsg = MAX_MESSAGE_COUNT;
_MsgQueueAttr.mq_msgsize = MAX_MESSAGE_LENGTH;
mqd_t _hMessageQueue = MESSAGE_QUEUE_ERROR;
_hMessageQueue = mq_open("temp.1234",
O_CREAT | O_RDWR | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
NULL);
if( MESSAGE_QUEUE_ERROR == _hMessageQueue)
{
printf("create queue failed.nr");
printf("%d", errno);
return -1;
}
mq_close(_hMessageQueue);
|
你这用的是哪个MQ哦?没头没脑的