#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
int main(int argc,char *argv[])
{
if(argc!=2)
{
printf(“not enough params,give pipefile name\n”);
exit(1);
}
char * pipefile;
pipefile=argv[1];
char buf[100];
int fd i;
printf(“read open namedpipe!\n”);
fd=open(pipefile,ORDONLY,0);
if(fd<0)
{
printf(“no such namedpipe file!!\n”);
exit(-1);
}
printf(“ok! namedpipe opened for read!\n”);
i=read(fd,buf,100);
buf[i]=0;
printf(“ok! readed from namedpipe:%s!\n”,buf);
return 0;
}
int main(int argc,char *argv[])
{
if(argc!=2)
{
printf(“not enough params,give pipefile name\n”);
exit(1);
}
char * pipefile;
pipefile=argv[1];
int fd;
char * teststr=“test strings!”;
printf(“open namedpipe–%s for write! \n”,pipefile);
fd=open(pipefile,O_WRONLY,0);
printf(“ok!namedpipe–%s opened for write! \n”,pipefile);
sleep(5);
write(fd,teststr,strlen(teststr));
printf(“ok! namedpipe write successfully! \n”);
exit(0);
}