Sunday, 1 September 2013

c - mqueue: message too long

c - mqueue: message too long

When I run the following program i have always the error message "Message
too long". Why?
this is the source:
#define NAME "/q"
#define SIZE 16
void main()
{
mqd_t mq;
char buffer[SIZE+1];
struct mq_attr attr;
attr.mq_flags = 0;
attr.mq_maxmsg = 10;
attr.mq_msgsize = SIZE;
attr.mq_curmsgs = 0;
mq = mq_open(NAME, O_CREAT | O_RDWR, 0644, &attr);
printf ("opening mqueue: %s\n", strerror(errno));
mq_receive(mq, buffer, strlen(buffer), NULL);
printf ("receiving: %s\n", strerror(errno));
printf ("message: %s\n", buffer);
unlink(NAME);
}
This is the outupt:
opening mqueue: Success
receiving: Message too long
message:

No comments:

Post a Comment