How to increase the message queue size in IPC in
the msgsnd() and msgrcv().
Code:
//file1.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/msg.h>
struct msgbuf {
int msgtype;
char msgtext[21];
}msg;
main()
{
int mid;
mid = msgget(012, IPC_CREAT);
if(mid < 0)
printf("\nError");
else {
msg.msgtype = 1;
printf("\nEnter the message: ");
scanf("%s", msg.msgtext);
msgsnd(mid, msg.msgtext, msg.msgtype, 0);
}
}
Code:
//file2.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/msg.h>
struct msgbuf {
int msgtype;
char msgtext[21];
}msg;
main()
{
int mid;
mid = msgget(012, IPC_CREAT);
if(mid < 0)
printf("\nError");
else {
msgrcv(mid, msg.msgtext, sizeof(msg.msgtext), 0, 0);
printf("\nRecieved message: %s", msg.msgtext);
}
msgctl(mid, IPC_RMID, NULL);
printf("\n");
}
When i enter hello world
the complete string doesn't be recieved.
Please help.
Please reply at the earliest.
Thank You.