I/O多路转接之select
来源:互联网 发布:共享网络无线发射器 编辑:程序博客网 时间:2024/04/29 21:07
中间的三个参数readset、writeset和exceptset指定我们要让内核测试读、写和异常条件的描述字。如果对某一个的条件不感兴趣,就可以把它设为空指针。struct fd_set可以理解为一个集合,这个集合中存放的是文件描述符,可通过以下四个宏进行设置:
void FD_ZERO(fd_set *fdset); //清空集合
void FD_SET(int fd, fd_set *fdset); //将一个给定的文件描述符加入集合之中
void FD_CLR(int fd, fd_set *fdset); //将一个给定的文件描述符从集合中删除
int FD_ISSET(int fd, fd_set *fdset); // 检查集合中指定的文件描述符是否可以读写
timeout告知内核等待所指定描述字中的任何一个就绪可花多少时间。其timeval结构用于指定这段时间的秒数和微秒数。
struct timeval{
long tv_sec; //seconds
long tv_usec; //microseconds
这个参数有三种可能:
1)永远等待下去:仅在有一个描述字准备好I/O时才返回。为此,把该参数设置为空指针NULL。
2)等待一段固定时间:在有一个描述字准备好I/O时返回,但是不超过由该参数所指向的timeval结构中指定的秒数和微秒数。
说明:
1、select只负责等待IO,不负责对IO进行操作,由recv/send等函数进行
2、select一共有两次系统调用:1)select系统调用 2)recvfrom系统调用
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之--select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select
- I/O多路转接之select、poll、epoll
- Linux下I/O多路转接之select --fd_set
- 【计算机网络】I/O多路转接之select
- linux—I/O多路转接之select
- 【Linux】中I/O多路转接之select
- I/O多路转接之select服务器
- UVALive5429 UVA382 POJ1528 HDU1323 ZOJ1284 Perfection
- Asp.Net开通支付宝PC端网页支付
- android app 开启自动启动
- 在mysql中,以下哪种方式可以开启一个事务?
- poj 1699 TSP(状态压缩DP + KMP)
- I/O多路转接之select
- Linux命令:改变文件或目录的访问权限
- 清除xcode缓存
- Android安全机制探讨
- ubuntu一键安装禅道系统
- UICollectionViewLayout
- 面向过程与面向对象
- HTML图片热区map area的用法整理
- 通过注解方式向Dao中注入Sessionfactory