How to write the program on full-duplex communication on
biderctional(e.g using two pipes)

Answer Posted / e.sridhar reddy

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/ipc.h>
#include<sys/types.h>
int main()
{
int p1[2],p2[2],i;
char buf[5];
pipe(p1);
pipe(p2);
if(fork()==0)
{
printf("\n this is child(the input text is text)\n");
close(p1[0]);
close(p2[1]);
write(p1[1],"text",5);
read(p2[0],buf,5);
write(1,buf,5);
}
else
{
printf("\n this is parent(the output text is text)\n");
close(p2[0]);
close(p1[1]);
read(p1[0],buf,5)
for(i=0;i<4;i++)
buf[i]=to upper(buf[i]);
write(p2[1],buf,5)
}
}

Is This Answer Correct ?    27 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what are the system calls used for process management?

701


Which ipc is the fastest in unix?

757


What is unix ipc?

742


What is ln(linking)?

790


What is i-node numbers?

821


Please describe the initial process sequence while the system boots up?

775


What is daemon?

750


What is the full form of ipc?

858


Explain the initial process sequence while the system boots up?

720


How to get or set an environment variable from a program?

731


Max relax-able permission value with out giving write permission to others?

773


Tell me set-user-id is related to (in unix)?

697


What is ipc in unix?

760


How to write the program on full-duplex communication on bidirectional(e.g using two pipes)?

766


Please explain fork() system call?

737