Network programming – Using ‘PIPE’ to communicate between two processes

#include<stdio.h>
#include<stdlib.h>
#include<errno.h>
int main()
{
 int desc[2];
 if(pipe(desc)==-1)
 {
   perror("pipe failed"); exit(0);
 }

 if(!fork())
 {
  write(desc[1],"hello",6);
 }
 else{
 char temp[20];
 read(desc[0],temp,6);
 printf("\n%s\n",temp);
 }
}

One thought on “Network programming – Using ‘PIPE’ to communicate between two processes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s