📄 server.c
字号:
#include "unpipc.h"voidserver(int readfd, int writefd){ int fd; ssize_t n; char buff[MAXLINE+1]; /* 4read pathname from IPC channel */ if ( (n = Read(readfd, buff, MAXLINE)) == 0) err_quit("end-of-file while reading pathname"); buff[n] = '\0'; /* null terminate pathname */ if ( (fd = open(buff, O_RDONLY)) < 0) { /* 4error: must tell client */ snprintf(buff + n, sizeof(buff) - n, ": can't open, %s\n", strerror(errno)); n = strlen(buff); Write(writefd, buff, n); } else { /* 4open succeeded: copy file to IPC channel */ while ( (n = Read(fd, buff, MAXLINE)) > 0) Write(writefd, buff, n); Close(fd); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -