⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strcliselect01.c

📁 unix网络编程卷1:套接口API的全书源码
💻 C
字号:
#include	"unp.h"voidstr_cli(FILE *fp, int sockfd){	int			maxfdp1;	fd_set		rset;	char		sendline[MAXLINE], recvline[MAXLINE];	FD_ZERO(&rset);	for ( ; ; ) {		FD_SET(fileno(fp), &rset);		FD_SET(sockfd, &rset);		maxfdp1 = max(fileno(fp), sockfd) + 1;		Select(maxfdp1, &rset, NULL, NULL, NULL);		if (FD_ISSET(sockfd, &rset)) {	/* socket is readable */			if (Readline(sockfd, recvline, MAXLINE) == 0)				err_quit("str_cli: server terminated prematurely");			Fputs(recvline, stdout);		}		if (FD_ISSET(fileno(fp), &rset)) {  /* input is readable */			if (Fgets(sendline, MAXLINE, fp) == NULL)				return;		/* all done */			Writen(sockfd, sendline, strlen(sendline));		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -