/MY PROGRAM ARE COMPILED IN FEDORA15 ..WITH 4.6 gcc compiler...../
/* SENDER */ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/ipc.h> #include<sys/msg.h> struct anu { unsigned long type; unsigned char *payload; }; struct anu a; unsigned char *payload; int main() { int kid,ret; kid=msgget(412,666|IPC_CREAT); a.type=13; a.payload="ANU IS ALWAYS LEFT BUT RIGHT"; printf("a.payload=%s",a.payload); printf("kid=%d\n",kid); if(!msgsnd(kid,a.payload,28,IPC_NOWAIT))//send the message printf("msg is snd succesfully\n"); return 0; }
s.pay=malloc(30);//if u r using pointer malloc it..other o/p will not be printed
kid=msgget(412,666|IPC_CREAT);
printf("kid=%d\n",kid);
if(msgrcv(kid,s.pay,28,0,IPC_NOWAIT)==-1)//u may get message directly into s.pay or get into &s with type (block no.) also..............MESSAGE RCV will return no. of characters received int value....