/* Pipes ( Echo Server Program */
20/10/2010 22:42
/*any write to write end will immediately be reflected at read end */
#include<stdio.h>
#define MSGSIZE 16
int main()
{
char *msg1="hello world#1";
char *msg2="hello world#2";
char *msg3="hello world#3";
char inbuf[MSGSIZE];
int p[2],j;
pipe(p);
write(p[1],msg1,MSGSIZE);
write(p[1],msg2,MSGSIZE);
write(p[1],msg3,MSGSIZE);
for(j=0;j<3;j++)
{
read(p[0],inbuf,MSGSIZE);
printf("%s\n",inbuf);
}
exit(0);
}