servaccept.c
来自「APUE(第二版)的随书源代码,与第一版的代码相比增加了一些章节的代码(详见第二」· C语言 代码 · 共 22 行
C
22 行
#include <sys/types.h>#include <sys/stat.h>#include <stropts.h>#include "ourhdr.h"/* Wait for a client connection to arrive, and accept it. * We also obtain the client's user ID. */int /* returns new fd if all OK, -1 on error */serv_accept(int listenfd, uid_t *uidptr){ struct strrecvfd recvfd; if (ioctl(listenfd, I_RECVFD, &recvfd) < 0) return(-1); /* could be EINTR if signal caught */ if (uidptr != NULL) *uidptr = recvfd.uid; /* effective uid of caller */ return(recvfd.fd); /* return the new descriptor */}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?