📄 server.c
字号:
#include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<string.h> int main(){ char buff[200]; int n,fl,fl2,file; mkfifo("fifo1",S_IFIFO|0666); /*creation of wellknown fifo*/ mkfifo("fifo2",S_IFIFO|0666); /*creation of client specific fifo*/ printf("server online"); fl=open("fifo1",O_RDONLY); printf("server waiting for client request"); n=read(fl,buff,128); buff[n]='\0'; close(fl); if((file=open(buff,O_RDONLY))<0) { printf("%s does not exist",buff); exit(1); } printf("server transfering contents"); sleep(2); fl2=open("fifo2",O_WRONLY); while((n=read(file,buff,128))>0) write(fl2,buff,n); close(file); close(fl2); printf("server completed"); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -