... ...
一般用不上writeSet,现在的网速很惊人的,网卡缓冲区也大,所以一检测就是【可写】的状态,因此不需要检测,特别是UDP,只要有网卡,任何时刻都是writable。error位倒是很有用。一般我们这样使用select:
r = select(max_socket_fd + 1, &readSet, 0, &errorSet, &time_out);
select函数:
系统提供select函数来实现多路复用输入/输出模型。原型:
int select(int maxfd,fd_set *rdset,fd_set *wrset,fd_set *exset,struct timeval *timeout);
多路复用的方式是真正实用的服务器程序,非多路复用的网络程序只能作为学习或着陪测的角色。
个人
接触过的多路复用函数:select/poll/epoll/port
评论