0% found this document useful (0 votes)
40 views

Ipc Receive

This C program demonstrates receiving a message from a message queue using interprocess communication. The program first creates a message queue with a key of 27 and permissions of 0777. It then receives a message from the queue using msgrcv, specifying the queue ID, message buffer, buffer length, and message type of 0. The received message is printed out, demonstrating that it has successfully received the message from the queue.

Uploaded by

PavithraRam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Ipc Receive

This C program demonstrates receiving a message from a message queue using interprocess communication. The program first creates a message queue with a key of 27 and permissions of 0777. It then receives a message from the queue using msgrcv, specifying the queue ID, message buffer, buffer length, and message type of 0. The received message is printed out, demonstrating that it has successfully received the message from the queue.

Uploaded by

PavithraRam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

K.

APARNA
412512104009
INTERPROCESS COMMUNICATION-TO RECEIVE A MESSAGE
#include<stdio.h>
#include<sys/types.h>
#include<string.h>
#include<sys/ipc.h>
#include<unistd.h>
main()
{
int mid;
charmsg[200];
printf(\n Interprocess communication using message queues);
mid=msgget(27,IPC_CREAT|0777);
if(mid==1)
{
printf(Invalid message);
exit;
}
msgrcv(mid,msg,strlen(msg),0);
printf(Message is received,msg);
printf(The received message %s,msg);
}
OUTPUT:
[cse2a@sys-do8~] $ vireceive.c
[cse2a@sys-do8~] $ cc receive.c
[cse2a@sys-do8~] $ ./a.out
Interprocess communication using message queues
Message is received
The received message is Hello

You might also like