Can any one tell me how to use MSG_EXCEPT flag in "msgrcv" function on message queue with example?
I am trying to do it but it will give me an error like : MSG_EXCEPT undeclared I have entered all the header files for "msgrcv" function.
please give me solution with sample code.
I am uploading my sample code of receiver side.
Receiver.c
#include <stdio.h>
#include <sys/msg.h>
#include <error.h>
#include <strings.h>
#include <mqueue.h>
#include <sys/ipc.h>
#include <sys/types.h>
int main()
{
int msqid;
struct message
{
long type;
char text[20];
} msg;
struct msqid_ds buf;
int msgtype = 3;
int num_messages;
int count;
int key = 1234;
msqid = msgget(key,0644);
count = msgctl(msqid,IPC_STAT,&buf);
num_messages = buf.msg_qnum;
printf("Number of messages = %d\n",num_messages);
if (msgrcv(msqid, (void *) &msg, sizeof(msg.text),4, MSG_EXCEPT | MSG_NOERROR | IPC_NOWAIT)==-1)
{
perror("msgrcv");
}
if(num_messages==0)
{
printf("Queue is empty\n");
}
else
{
printf("%s \n", msg.text);
}
return 0;
}