head 1.2;
access;
symbols;
locks
arjun:1.2; strict;
comment @ * @;
1.2
date 2014.03.25.08.06.10; author arjun; state Exp;
branches;
next 1.1;
1.1
date 2014.03.25.05.16.16; author arjun; state Exp;
branches;
next ;
desc
@we are using 2 pipe for requesting client and same for processing client
but not use switch case in server.
@
1.2
log
@we are using switch case in server to find out the operator.
@
text
@#include
#include
int main()
{
int i,pfd1[2],pfd2[2],pfd3[2],pfd4[2],pid1,pid2,pid3,pid4,pid5,pid6,ret1r,ret1w,ret2r,ret2w,ret3r,ret3w,ret4r,ret4w,ret5r,ret5w,ret6r,ret6w,ret1,ret2,ret3,ret4,buf1[4],buf2[4],buf3[4],buf4[4],addres,subres,mulres,ch;
char a[4],b[4],c[4],d[4],e[4],f[4],g[4],h[4];
ret1=pipe(pfd1);
ret2=pipe(pfd2);
ret3=pipe(pfd3);
ret4=pipe(pfd4);
sprintf(a,”%d”,pfd1[0]);
sprintf(b,”%d”,pfd1[1]);
sprintf(c,”%d”,pfd2[0]);
sprintf(d,”%d”,pfd2[1]);
sprintf(e,”%d”,pfd3[0]);
sprintf(f,”%d”,pfd3[1]);
sprintf(g,”%d”,pfd4[0]);
sprintf(h,”%d”,pfd4[1]);
pid1=fork();
if(pid1>0)
{
printf(“i am parent\n”);
ret1r=read(pfd1[0],buf1,12);
pid2=fork();
if(pid2==0)
{
printf(“i am child2\n”);
execl(“./cl2″,”arjun”,b,c,NULL);
}
else
{
ret2r=read(pfd1[0],buf2,12);
}
pid3=fork();
if(pid3==0)
{
printf(“i am child3\n”);
execl(“./cl3″,”arjun”,b,c,NULL);
}
else
{
ret3r=read(pfd1[0],buf3,12);
}
int *buff4[3]={(int*)buf1,(int*)buf2,(int*)buf3};
for(i=0;i<3;i++)
{
ch= *((int*)buff4[i]);
switch(ch)
{
case 43:
{
pid4=fork();
if(pid4==0)
{
ret4w=write(pfd3[1],buf1,12);
printf("i am pchild1\n");
execl("./pcl1","arjun",e,h,NULL);
}
else
{
ret4r=read(pfd4[0],&addres,4);
ret1w=write(pfd2[1],&addres,4);
}
}
break;
case 45:
{
pid5=fork();
if(pid5==0)
{
ret5w=write(pfd3[1],buf2,12);
printf("i am pchild2\n");
execl("./pcl2","arjun",e,h,NULL);
}
else
{
ret5r=read(pfd4[0],&subres,4);
ret2w=write(pfd2[1],&subres,4);
}
}
break;
default :
{
pid6=fork();
if(pid6==0)
{
ret6w=write(pfd3[1],buf2,12);
printf("i am pchild3\n");
execl("./pcl3","arjun",e,h,NULL);
}
else
{
ret6r=read(pfd4[0],&subres,4);
ret3w=write(pfd2[1],&subres,4);
}
}
break;
}
}
}
else
{
printf("i am child1\n");
execl("./cl1","arjun",b,c,NULL);
}
}
@
1.1
log
@Initial revision
@
text
@d5 1
a5 1
int i,pfd1[2],pfd2[2],pfd3[2],pfd4[2],pid1,pid2,pid3,pid4,pid5,pid6,ret1r,ret1w,ret2r,ret2w,ret3r,ret3w,ret4r,ret4w,ret5r,ret5w,ret6r,ret6w,ret1,ret2,ret3,ret4,buf1[4],buf2[4],buf3[4],buf4[4],addres,subres,mulres;
d48 2
a49 3
pid4=fork();
if(pid4==0)
d51 52
a102 3
ret4w=write(pfd3[1],buf1,12);
printf("i am pchild1\n");
execl("./pcl1","arjun",e,h,NULL);
a103 32
else
{
ret4r=read(pfd4[0],&addres,4);
ret1w=write(pfd2[1],&addres,4);
}
pid5=fork();
if(pid5==0)
{
ret5w=write(pfd3[1],buf2,12);
printf("i am pchild2\n");
execl("./pcl2","arjun",e,h,NULL);
}
else
{
ret5r=read(pfd4[0],&subres,4);
ret2w=write(pfd2[1],&subres,4);
}
pid6=fork();
if(pid6==0)
{
ret6w=write(pfd3[1],buf2,12);
printf("i am pchild3\n");
execl("./pcl3","arjun",e,h,NULL);
}
else
{
ret6r=read(pfd4[0],&subres,4);
ret3w=write(pfd2[1],&subres,4);
}
@