摘要: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <string.h> 5 #define MAXBUFSIZE 1024 6 #define WAIT_SECOND 3 //暂停时间,单位为“秒” 阅读全文
posted @ 2019-12-31 19:25 嗷嗷鹿鸣[VX|dshoub] 阅读(1132) 评论(0) 推荐(0) 编辑
摘要: 重点:accept后fork,子进程和父进程共享两个fd,一个是 监听fd,一个是客户端socketfd,。 子进程需要关闭监听套接字fd,父进程需要关闭客户端套接字fd进行继续accept. 这样子进程就可以对客户端进行读写了。 服务器代码.c #include<sys/types.h> #inc 阅读全文
posted @ 2019-12-31 19:06 嗷嗷鹿鸣[VX|dshoub] 阅读(558) 评论(0) 推荐(0) 编辑