FIFO SERVER  

Posted in

FIFO
server:

#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);
rd=open(FIFO1,O_RDONLY);
read(rd,&fn,sizeof(fn));
wd=open(FIFO2,O_WRONLY);
fp=fopen(fn,"r");
if(fp==NULL)
{
printf("file cant be created\n");
//next two lines r newly added
i=0;
write(wd,&i,sizeof(i));
exit(0);
}
while((c=fgetc(fp))!=EOF)
{
buff[i]=c;
i++;
}
write(wd,&i,sizeof(i));
write(wd,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.