Design and Develop program for creating a private message queue.

AIM:

Design and Develop program for creating a private message queue.

Program:

#include<stdio.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>
void main()
{
   int queue_id;
   /*create a private messaga queue,with access only to the owner*/
   queue_id=msgget(IPC_PRIVATE,0600);
   if(queue_id==-1)
   {
      perror(“msgget”);
      exit(1);
   }
   printf(“message queue ID=%d\n”,queue_id);
}

Output:

guest-b7wxtw@ubuntu:~$gcc –o message.out  message.c
guest-b7wxtw@ubuntu:~$./message.out
message queue ID:32769