head 1.2;
access;
symbols;
locks
poonam:1.2; strict;
comment @ * @;
1.2
date 2014.03.25.05.06.08; author poonam; state Exp;
branches;
next 1.1;
1.1
date 2014.03.25.02.12.49; author poonam; state Exp;
branches;
next ;
desc
@implemented server with three requesting client and three processing client bt result is not perfect for each requesting client.
@
1.2
log
@used switch to run different processing clients.
@
text
@#include”header.h”
int main()
{
int i,pipe1,pipe2,pipe3,pipe4,data_r1,data_r2,data_r3,data_add,data_sub,data_mul,plus[2],plus_r,plus_w,minus[2],minus_r,minus_w,mul[2],mul_r,mul_w;
int pid1,pid2,pid3,pid4,pid5,pid6,ch;
int fd_com_req[2], fd_com_res[2],fd_com_preq[2],fd_com_pres[2];
char a[4],b[4],c[4],d[4],e[4],f[4],g[4],h[4];
int buf_client1_r[3], buf_client2_r[3], buf_client3_r[3];
pipe1=pipe(fd_com_req);
pipe2=pipe(fd_com_res);
pipe3=pipe(fd_com_preq);
pipe4=pipe(fd_com_pres);
sprintf(a,”%d”,fd_com_req[1]);
sprintf(b,”%d”,fd_com_req[0]);
sprintf(c,”%d”,fd_com_res[1]);
sprintf(d,”%d”,fd_com_res[0]);
sprintf(e,”%d”,fd_com_preq[1]);
sprintf(f,”%d”,fd_com_preq[0]);
sprintf(g,”%d”,fd_com_pres[1]);
sprintf(h,”%d”,fd_com_pres[0]);
printf(“this is server\n”);
pid1=fork();
if(pid1!=0)
{
data_r1=read(fd_com_req[0],buf_client1_r,12);
for(i=0;i<3;i++)
printf("client1[%d]=%d\n",i,buf_client1_r[i]);
pid2=fork();
if(pid2!=0)
{
data_r2=read(fd_com_req[0],buf_client2_r,12);
for(i=0;i<3;i++)
printf("client2[%d]=%d\n",i,buf_client2_r[i]);
pid3=fork();
if(pid3!=0)
{
data_r3=read(fd_com_req[0],buf_client3_r,12);
for(i=0;i<3;i++)
printf("client3[%d]=%d\n",i,buf_client3_r[i]);
int *server_buf[3] = {(int*) (buf_client1_r+0), (int*)(buf_client2_r+0),(int*)(buf_client3_r+0)};
for(i=0;i<3;i++)
{
printf("server buf %d \n",*((int*)server_buf[i]));
ch = *((int*)server_buf[i]);
switch(ch)
{
case 43: printf("add \n");
pid4=fork();
if(pid4!=0)
{
plus_r = read(fd_com_pres[0],plus,8);
printf("plus result is =%d\n",plus[1]);
plus_w = write(fd_com_res[1],plus,8);
}
else
{
data_add = write(fd_com_preq[1],buf_client1_r,12);
execl("./add","add",f,g,NULL);
}
break;
case 45: pid5=fork();
if(pid5!=0)
{
minus_r = read(fd_com_pres[0],minus,8);
printf("minus result is =%d\n",minus[1]);
minus_w = write(fd_com_res[1],minus,8);
}
else
{
data_sub = write(fd_com_preq[1],buf_client2_r,12);
execl("./sub","sub",f,g,NULL);
}
break;
case 42: pid6=fork();
if(pid6!=0)
{
mul_r = read(fd_com_pres[0],mul,8);
printf("mul result is =%d\n",mul[1]);
mul_w = write(fd_com_res[1],mul,8);
}
else
{
data_mul = write(fd_com_preq[1],buf_client3_r,12);
execl("./mul","mul",f,g,NULL);
}
break;
}
/* else
{
data_sub = write(fd_com_preq[1],buf_client2_r,12);
execl("./sub","sub",f,g,NULL);
}
}
else
{
data_add = write(fd_com_preq[1],buf_client1_r,12);
execl("./add","add",f,g,NULL);
}*/
}
}
else
{
execl("./cl3","client3",a,d,NULL);
}
}
else
{
execl("./cl2","client2",a,d,NULL);
}
}
else
{
execl("./cl1","client1",a,d,NULL);
}
}
@
1.1
log
@Initial revision
@
text
@d5 1
a5 1
int pid1,pid2,pid3,pid4,pid5,pid6;
d40 47
a86 22
//printf("clients req are \n");
pid4=fork();
if(pid4!=0)
{
plus_r = read(fd_com_pres[0],plus,8);
printf("plus result is =%d\n",plus[1]);
plus_w = write(fd_com_res[1],plus,8);
pid5=fork();
if(pid5!=0)
{
minus_r = read(fd_com_pres[0],minus,8);
printf("minus result is =%d\n",minus[1]);
minus_w = write(fd_com_res[1],minus,8);
pid6=fork();
if(pid6!=0)
{
mul_r = read(fd_com_pres[0],mul,8);
printf("mul result is =%d\n",mul[1]);
mul_w = write(fd_com_res[1],mul,8);
}
else
{
d90 2
a91 1
}
d93 1
a93 1
else
d106 2
a107 1
}
d109 1
@