上一节简单的介绍了服务器消息处理的流程,想必大家对这方面有了初步的认识,接下来我们需要知道和掌握的便是其中一些重要的方法,进一步深入熟悉整个构架。 1、FD_*系列宏函数 FD_ZERO(fd_set *fdset) 将指定的文件描述符集清空,在对文件描述符集合进行设置前,必须对其进行初始化,如.....
分类:
Web程序 时间:
2014-11-09 11:12:36
阅读次数:
327
网络编程中,我们经常讨论等待某个描述符准备好I/O(读/写)或者等待其上发生一个待处理的异常条件。尽管可读性和可写性对于普通文件这样的描述符显而易见,然而对于引起诸如select返回套接字“就绪”的条件我们必须讨论的更明确些。
套接字Select函数原型:
#include
#include
int select(int maxfdp1, fd_set *readset, fd_set ...
分类:
其他好文 时间:
2014-11-05 13:03:13
阅读次数:
249
select函数用于在非阻塞中,当一个套接字或一组套接字有信号时通知你,系统提供select函数来实现多路复用输入/输出模型,原型:int select(int maxfd,fd_set *rdset,fd_set *wrset,fd_set *exset,struct timeval *timeo...
分类:
其他好文 时间:
2014-10-29 19:01:50
阅读次数:
230
man select:#include #include int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval ...
分类:
系统相关 时间:
2014-10-17 15:02:59
阅读次数:
218
pselect函数是由POSIX发明的,如今许多Unix变种都支持它。#include #include #include int pselect(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const st....
分类:
其他好文 时间:
2014-09-23 17:02:04
阅读次数:
200
原型intselect(intnfds,fd_set*readfds,fd_set*writefds,fd_set*exceptfds,const struct timeval*timeout);nfds:本参数忽略,仅起到兼容作用。 readfds:(可选)指针,指向一组等待可读性检查的套接口。 ...
分类:
其他好文 时间:
2014-09-22 16:15:42
阅读次数:
319
1. Select源码解析
基于2.6.28内核代码,select主要包含4个函数。
sys_select:处理时间参数,然后调用core_sys_select。
core_sys_select:处理三个fd_set参数(in, out, ex),然后调用do_select。
do_select:遍历所有的fd,做select/poll的工作。在合适的时机把...
分类:
其他好文 时间:
2014-09-19 01:12:44
阅读次数:
192
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
int epoll_wait(int epfd, struct...
分类:
其他好文 时间:
2014-09-17 23:23:42
阅读次数:
325
日常开发中,经常碰到处理程序阻塞的情况:1.select函数select函数用于确定一个或多个套接口的状态,对每一个套接口,调用者可查询它的可读性、可写性及错误状态信息,用fd_set结构来表示一组等待检查的套接口,在调用返回时,这个结构存有满足一定条件的套接口组的子集,并且select()返回满足...
分类:
其他好文 时间:
2014-09-17 11:37:32
阅读次数:
1394
一、selectwinsock中#include 原型intselect(intnfds,fd_set*readfds,fd_set*writefds,fd_set*exceptfds,const struct timeval*timeout);nfds:本参数忽略,仅起到兼容作用。readfds:...
分类:
其他好文 时间:
2014-09-17 02:19:01
阅读次数:
298