head 1.7;
access;
symbols;
locks
ashish:1.7; strict;
comment @ * @;
1.7
date 2015.03.16.21.25.33; author ashish; state Exp;
branches;
next 1.6;
1.6
date 2015.03.16.21.22.29; author ashish; state Exp;
branches;
next 1.5;
1.5
date 2015.03.16.21.17.18; author ashish; state Exp;
branches;
next 1.4;
1.4
date 2015.03.16.21.09.27; author ashish; state Exp;
branches;
next 1.3;
1.3
date 2015.03.16.21.07.19; author ashish; state Exp;
branches;
next 1.2;
1.2
date 2015.03.16.21.03.47; author ashish; state Exp;
branches;
next 1.1;
1.1
date 2015.03.16.17.18.55; author ashish; state Exp;
branches;
next ;
desc
@including the header
creating a message queue for for receing and sending the data.
creating another msgque for receiving and sending the result
@
1.7
log
@now the received result would be written in the req client using msgsnd()
@
text
@#include”header_mq.h”//header containing the header files ,a structure which is having the variable for number and operator,union semun used for semaphore,and a sem buffer//
int main()
{
int mq_req,mq_res,mq_send,mq_recv,ret,p1[2],w1,result;
char a[4],b[4];
struct mesg req;
mq_req=msgget(620,IPC_CREAT|0666);//creating the message queue for requesting which have the a unique keyid,and mode//
if(mq_req==-1)
{
printf(“error\n”);
exit(1);
}
printf(“created for sending req\n”);
mq_res=msgget(720,IPC_CREAT|0666);//creating another message queue for taking result,with another unique keyid,and the mod//
if(mq_res==-1)
{
printf(“error1\n”);
exit(1);
}
printf(“created for result\n”);
while(1)
{
mq_recv=msgrcv(mq_req,&req,sizeof(struct mesg),0,0);//s is the message receive fun() which will receive the message from the mesg queue,where the argu says,id which have been return by the mesg queue creat(),second is the ptr which will point to the message receive,then size of the mesg pntd by the ptr,mesg type,and messg flag//
if(mq_recv==-1)
{
printf(“error2\n”);
exit(1);
}
printf(“created for receiving\n”);
printf(“readed data is %d %c %d\n”,req.data.num1,req.data.operator,req.data.num2);//here the data from the client have been received by the use of mmessg recv()//
pipe(p1);//createing the pipe for accessing the procc client//
printf(“pipe1 have been created\nrfd->%d\nwfd->%d\n”,p1[0],p1[1]);
ret=fork();//fork have been done to creat a child and parent proceess//
if(ret==0)
{
printf(“child\n”);
printf(“c1\n”);
write(p1[1],&req,sizeof(struct mesg));//writing the data in the process client using write(),and doing the execl to enter in proc clint//
sprintf(a,”%d”,p1[0]);
sprintf(b,”%d”,p1[1]);
printf(“c2\n”);
// execl(“/home/ashish/ash/pj3/messagequeue/proc”,”./proc”,a,b,NULL);//use to access the proc where the switch is used to go in diff operation such as,addition,sub,div,ettc,,//
}
else
{ wait(&w1);
printf(“parent\n”);
// read(p1[0],&result,sizeof(int));//reading the result from the proc client//
printf(“server result->%d\n”,result);
mq_send=msgsnd(mq_res,&result,sizeof(int),0);//here the received result is send to the req client,where the final result is stored//
}
}
}
@
1.6
log
@result have been written to the parent by the proc client
@
text
@d50 1
a50 1
read(p1[0],&result,sizeof(int));//reading the result from the proc client//
@
1.5
log
@*** empty log message ***
@
text
@d45 1
a45 1
execl(“/home/ashish/ash/pj3/messagequeue/proc”,”./proc”,a,b,NULL);//use to access the proc where the switch is used to go in diff operation such as,addition,sub,div,ettc,,//
@
1.4
log
@writing the data received from req client to the proc client
then accessing the proc client by doing the execl.
@
text
@d45 1
a45 1
// execl(“/home/ashish/ash/pj3/messagequeue/proc”,”./proc”,a,b,NULL);//use to access the proc where the switch is used to go in diff operation such as,addition,sub,div,ettc,,//
@
1.3
log
@now a pipe is created which returns the fd for read and write.
doing a fork so that a child andd parent can be created.
reading the data before doing fork,from the req client
@
text
@d45 1
a45 1
execl(“/home/ashish/ash/pj3/messagequeue/proc”,”./proc”,a,b,NULL);//use to access the proc where the switch is used to go in diff operation such as,addition,sub,div,ettc,,//
@
1.2
log
@now putting a while loop.
in this loop furthe programming would be done
now creting a messg receving (),which will have the arg as,1.id return by the mesgque created,2.a ptr which will points to the messg to be received,3.this is the size of the message pts by the ptr,and then messg type and flag
@
text
@d32 1
@
1.1
log
@Initial revision
@
text
@d25 1
@