![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unable to extract a tag from a very long XML message | Sapna_Sai | UNIX for Dummies Questions & Answers | 3 | 05-13-2009 11:28 AM |
| How to limit max no of message in a posix message queue | mohit3884 | High Level Programming | 0 | 06-10-2008 06:03 AM |
| POSIX message queue size | Vourhey | Linux | 7 | 06-09-2008 03:42 AM |
| posix ipc message queue | cadanir | HP-UX | 6 | 05-01-2006 08:59 PM |
| POSIX Message Queue - Settings | Deepa | High Level Programming | 0 | 02-07-2003 10:13 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
POSIX mq_receive issue: Message too long
Hello, I am trying to implement posix message queue application. I am faced with an error on the mq_receive section. It says "Message too long". I've tried couple of small tweeks, but to no result. Please do suggest any rectificaitons. mq_send section-works successfully Code:
#include <mqueue.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <string.h>
#include <signal.h>
#define MSG_SIZE 16
#define MQ_NAME "/msgqueue"
int main(void)
{
mqd_t mqPXId;
char *msg = "test";
if ((mqPXId = mq_open (MQ_NAME, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL)) ==-1)
{
printf ("sendTask: mq_open failed: %s\n", strerror(errno));
return 0;
}
if (mq_send (mqPXId, msg, MSG_SIZE, NULL) == -1)
{
printf ("sendTask: mq_send failed\n");
return 0;
}
else
{
printf ("sendTask: mq_send succeeded, msg sent: %s\n",msg);
}
return 0;
}
mq_receive section: error-Message too long Code:
#include <stdio.h>
#include <mqueue.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#define MSG_SIZE 16
#define MQ_NAME "/msgqueue"
int main(void)
{
mqd_t mqPXId; /* msg queue descriptor */
char *msg; /* msg buffer */
// unsigned int prio; /* priority of message */
/* open message queue using default attributes */
if ((mqPXId = mq_open (MQ_NAME, O_RDWR , S_IWUSR | S_IRUSR, NULL))
== -1)
{
printf ("receiveTask: mq_open failed\n");
return 0;
}
/* try reading from queue */
if (mq_receive (mqPXId,(char *)&msg,MSG_SIZE, NULL) == -1)
{
printf ("receiveTask: mq_receive failed: %s\n",strerror(errno));
return 0;
}
else
{
printf ("receiveTask: Msg of priority received:\n\t\t%s\n",
msg);
}
return 0;
}
|
| Bits Awarded / Charged to katwalatapan for this Post | |||
| Date | User | Comment | Amount |
| 09-10-2009 | vgersh99 | thanks for using the code tag on the FIRST post! | 3,000 |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|