The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
Sender
1. #include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
//SENDER PROCESS
//
//first start sender
//function open waits until receiver process has been started
#define MAX 100
void main ()
{
int fd;
char buf[MAX];
printf("Creating Pipe... Waiting for receiver process...nn");
//TRY TO CRATE A NAMED PIPE
if (mkfifo("FIFO_PIPE",0666)<0)
{
perror("FIFO (named pipe) could not be created.");
exit(-1);
}
else printf("nPipe has been created...");
//OPEN PIPE
if ((fd = open ("FIFO_PIPE", O_WRONLY))<0)
{
perror("Could not open named pipe.");
exit(-1);
}
else printf("Pipe has been opened.");
//WRITE TO PIPE
strcpy(buf,"Named Pipe experiment.");
if( write (fd,buf, strlen(buf)+1) < 0 )
{
perror("Error writing to named Pipe (FIFO)");
exit(-1);
}
else printf("Message has been written to pipe.");
//CLOSE FIFO
if (close(fd)<0)
{
perror("Error closing FIFO");
exit(-1);
}
exit(0);
}