标签:
#include<stdio.h>
#include<unistd.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>
#include<string.h>
int main()
{
char* msg = "Hello, i am client!\n";
int fd = open("./fifo1",O_WRONLY);
int i = 0;
for(;i<10;i++)
{
printf(msg);
if(write(fd,msg,strlen(msg)+1)<0)
{
_exit(-1);
}
sleep(2);
}
close(fd);
return 0;
}
#include<stdio.h>
#include<unistd.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>
#include<string.h>
int main()
{
int fd = open("./fifo1",O_RDONLY);
int i = 0;
char buf[24]={0};
while(read(fd,buf,24)>0)
{
printf(buf);
}
close(fd);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/ZhangJinkun/p/4563138.html