#include <sys/types.h> #include <sys/stat.h> int mknod(const char *path,mode_t mod,dev_t dev); int mkfifo(const char *path,mode_t mode);
umask(0);
if (mknod("/tmp/fifo",S_IFIFO | 0666) == -1)
{
perror("mkfifo error");
exit(1);
}
umask(0);
if (mkfifo("/tmp/fifo",S_IFIFO|0666) == -1)
{
perror("mkfifo error!");
exit(1);
}
#include<stdlib.h>
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<errno.h>
#define PATH "./fifo"
#define SIZE 128
int main()
{
umask(0);
if (mkfifo (PATH,0666|S_IFIFO) == -1)
{
perror ("mkefifo error");
exit(0);
}
int fd = open (PATH,O_RDONLY);
if (fd<0)
{
printf("open fd is errorn");
return 0;
}
char Buf[SIZE];
while(1){
ssize_t s = read(fd,Buf,sizeof(Buf));
if (s<0)
{
perror("read error");
exit(1);
}
else if (s == 0)
{
printf("client quit! i shoud quit!n");
break;
}
else
{
Buf[s] = ' ';
printf("client# %s ",Buf);
fflush(stdout);
}
}
close (fd);
return 3;
}
#include<stdlib.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<string.h>
#include<errno.h>
#include<fcntl.h>
#define PATH "./fifo"
#define SIZE 128
int main()
{
int fd = open(PATH,O_WRONLY);
if (fd < 0)
{
perror("open error");
exit(0);
}
char Buf[SIZE];
while(1)
{
printf("please Enter#:");
fflush(stdout);
ssize_t s = read(0,Buf,sizeof(Buf));
if (s<0)
{
perror("read is failed");
exit(1);
}
else if(s==0)
{
printf("read is closed!");
return 1;
}
else{
Buf[s]= ' ';
write(fd,Buf,strlen(Buf));
}
}
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有