C Program to show an example of Indirect Communication recieve : # include <stdio.h> # include <stdlib.h> # include <errno.h> # include <sys/types.h> # include <sys/msg.h> struct my_msgbuf { long mtype ; char mtext [ 200 ] ; } ; int main ( void ) { struct my_msgbuf buf ; int i = ftok ( "snd.c" , 'B' ) ; int msqid = msgget ( i , 0644 ) ; for ( ; ; ) { msgrcv ( msqid , & buf , sizeof ( buf . mtext ) , 0 , 0 ) ; printf ( "Recieving from message queue:%s\n" , buf . mtext ) ; } return ( 0 ) ; } send : # include <stdio.h> # include <stdlib.h> # include <errno.h> # include <string.h> # include <sys/types.h> # include <sys/msg.h> # include <sys/ipc.h> struct my_msgbuf { long mtype ; char mtext [ 200 ] ; } ; int main ( void ) { struct my_msgbuf buf ; int i = ftok ( "snd.c" , 'B' ) ; int msqid = msgget ( i , 0644 | IPC_CREAT ) ; printf ( "Enter the mess...
Get the latest unboxing and tech news at you fingertips. Collect Software and other precious data overtime