FIFO CLIENT  

Posted in

#include"sys/types.h"
#include"sys/stat.h"
#include"stdio.h"
#include"stdlib.h"
#include"fcntl.h"

#define FIFO1 "fifo1"
#define FIFO2 "fifo2"

void main()
{
FILE *fp;
char buff[2500],fn[100],c;
int rd,wd,i=0;
mknod(FIFO1,S_IFIFO|0666,0);
mknod(FIFO2,S_IFIFO|0666,0);
wd=open(FIFO1,O_WRONLY);
printf("enter filename");
scanf("%s",fn);
write(wd,fn,sizeof(fn));
rd=open(FIFO2,O_RDONLY);
read(rd,&i,sizeof(i));
//next two lines added
if(i==0)
printf("file doesnt exist\n");
else
{
read(rd,buff,i);
write(1,buff,i);
}
unlink(FIFO1);
unlink(FIFO2);
}

This entry was posted at 10:21 AM and is filed under . You can follow any responses to this entry through the comments feed .

0 comments

Post a Comment

Reverse Engineering :Subscribe Now

Zts - ZTS

DISCLAIMER

This Blog is ONLY for educational purposes,
and any such codes/snippets provided are to be executed on
your sole discretion. The author is not responsible for the codes.