|
#define FIFO1 "./myfifo1"
main(int argc,char** argv)
{char buf_r[100],w_buf[100]="1111111";
int fd,fd1;
int nread,nwrite;
/* 创建管道1*/
unlink(FIFO1); //删除文件
if((mkfifo(FIFO1,O_CREAT|O_EXCL)<0)&&(errno!=EEXIST))
printf("cannot create fifoserver1\n");
printf("FIFO1 create\n");
/*打开管道1*/
fd1=open(FIFO1,O_WRONLY|O_NONBLOCK,0);
printf("FIFO1 createsdfdsfsdf\n");
while(1)
{
/*...............................................
...............................................
...............................................*/
sleep(1);
/* 向管道1 写入数据 */
if((nwrite=write(fd1,w_buf,100))==-1)
{printf("FIFO1 create...\n");
if(errno==EAGAIN)
printf("The FIFO has not been read yet.Please try later\n");
}
else
printf("write %s to the FIFO1\n",w_buf);
}
}
您说这里那里有错?为什么总是写入有错误??? |
|