linux 下 select 编程 librtspserver.rar

上传者: sunshineywz | 上传时间: 2021-01-28 03:44:17 | 文件大小: 68KB | 文件类型: RAR
c++
linux 下 select 编程 我们知道 select 是IO 多路复用的一个最简单支持,poll 和 epoll 是 select 的升级版。在 UNIX 网络编程第五章读书笔记 我们遇到这样一个问题:当客户端阻塞在 fgets() 等待客户输入的时候,服务器端断开连接。而客户端却不能及时知道,只有在客户输入完毕并发送到服务器的时候才知道连接已经断开,但是此时可能已经过了很长时间了。如果我们想及时知道服务器断开连接怎么办呢?   我们知道不管是 fgets() 等待客户输入还是 read() 从套接口读取数据,都是 IO 操作。我们不能阻塞在某个 IO 操作中一个,这样其他 IO 操作会无法进行,即使其他 IO 操作上有数据了我们也无法及时读取。select 的原理是这样的:我们将这些 IO 操作所要操作的文件描述符放到一起(比如一个数组中),然后阻塞在 select() 函数上,为什么要阻塞在这里呢?其实这时的 select 实在不停的遍历这个数组,查看其中的文件描述符上是否可读/可写,一旦可读/可写,select 返回,停止阻塞。然后我们对可读/可写的文件描述如做相应的操作即可。下面是 select 函数的原型:   int select(nfds, readfds, writefds, exceptfds, timeout)   nfds 是指定 select() 要遍历的最大文件描述符 + 1,readfds 就是放文件描述的数组,这个数组里面关心的是该数组中文件描述符的读事件,wretefds 也是放文件描述符的数组,这个数组里面关心的是该数组中文件描述符的写事件,exceptfds 也是放文件描述符的数组,这个数组关心的是该数组中文件描述符的出错事件。timeout 是 select 阻塞的时间。如果设置为 空指针,那么将永远阻塞下去直到某个描述符有事件发生(就绪)。否则的话就会在阻塞由 timeout 指定的时间后返回,无论关心的文件描述符是否有事件发生。select 返回有事件发生的文件描述符个数,失败返回 -1,超时返回 0!

文件下载

资源详情

[{"title":"( 40 个子文件 68KB ) linux 下 select 编程 librtspserver.rar","children":[{"title":"librtspserver","children":[{"title":"UnitTest_rtspRtp.c <span style='color:#111;'> 8.35KB </span>","children":null,"spread":false},{"title":"Makefile-NT <span style='color:#111;'> 602B </span>","children":null,"spread":false},{"title":"UnitTest_rtspServer.h <span style='color:#111;'> 5.93KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspParser.c <span style='color:#111;'> 12.61KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspParser.h <span style='color:#111;'> 1.27KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspUser.h <span style='color:#111;'> 1.47KB </span>","children":null,"spread":false},{"title":"Makefile-hi3559a <span style='color:#111;'> 474B </span>","children":null,"spread":false},{"title":"UnitTest_rtspList.h <span style='color:#111;'> 22.46KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspUser.c <span style='color:#111;'> 5.53KB </span>","children":null,"spread":false},{"title":"Makefile-hi3516av200 <span style='color:#111;'> 466B </span>","children":null,"spread":false},{"title":"UnitTest_rtspUtil.c <span style='color:#111;'> 7.63KB </span>","children":null,"spread":false},{"title":"rtspServer.h <span style='color:#111;'> 3.94KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspCmd.c <span style='color:#111;'> 23.29KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspUtil.h <span style='color:#111;'> 1.50KB </span>","children":null,"spread":false},{"title":"Makefile <span style='color:#111;'> 474B </span>","children":null,"spread":false},{"title":".svn","children":[{"title":"pristine","children":[{"title":"1e","children":[{"title":"1e1c5ba6dcdcaf6f7942587e29b2673e0dccd27c.svn-base <span style='color:#111;'> 1.47KB </span>","children":null,"spread":false}],"spread":false},{"title":"0b","children":[{"title":"0b9d1788b80c939d8d3818fd04610a3fcf57c1ac.svn-base <span style='color:#111;'> 25.74KB </span>","children":null,"spread":false}],"spread":false},{"title":"d5","children":[{"title":"d5c35e7dde1eff77df4f3753e6a3375ea8f57ce5.svn-base <span style='color:#111;'> 474B </span>","children":null,"spread":false}],"spread":false},{"title":"be","children":[{"title":"be56c998b78181753c96d1573860c8f25e4c2459.svn-base <span style='color:#111;'> 63B </span>","children":null,"spread":false}],"spread":false},{"title":"1a","children":[{"title":"1ae00a1efa30aa8560b07d0a4e082f1e36df0cff.svn-base <span style='color:#111;'> 12.61KB </span>","children":null,"spread":false}],"spread":false},{"title":"5d","children":[{"title":"5dd98bab073f62076d407db74803c30daf8334b0.svn-base <span style='color:#111;'> 3.94KB </span>","children":null,"spread":false}],"spread":false},{"title":"c5","children":[{"title":"c5a906425cbf01957e6979d89c83bfd0931e6bdb.svn-base <span style='color:#111;'> 8.35KB </span>","children":null,"spread":false}],"spread":false},{"title":"10","children":[{"title":"10bb974ba0d9d7aeace63f918ae2309cc9a9a235.svn-base <span style='color:#111;'> 5.93KB </span>","children":null,"spread":false}],"spread":false},{"title":"dd","children":[{"title":"dd4fd9af26c8317793a4d3867464ad959abc490b.svn-base <span style='color:#111;'> 602B </span>","children":null,"spread":false}],"spread":false},{"title":"f6","children":[{"title":"f6c593871ed26cadc0b63ac9c029a65bc9acc658.svn-base <span style='color:#111;'> 1.50KB </span>","children":null,"spread":false}],"spread":false},{"title":"cb","children":[{"title":"cb7ebeb7211d93df0e5e47f8f541cbfb6e35b314.svn-base <span style='color:#111;'> 22.46KB </span>","children":null,"spread":false}],"spread":false},{"title":"63","children":[{"title":"630f6aeaf756e1b2857d1e990ff418c844742d89.svn-base <span style='color:#111;'> 5.53KB </span>","children":null,"spread":false}],"spread":false},{"title":"49","children":[{"title":"4940a91b2dc4902dacb9aaf1eac7978df1d2d6de.svn-base <span style='color:#111;'> 7.63KB </span>","children":null,"spread":false}],"spread":false},{"title":"0d","children":[{"title":"0d4f6263f2e4414778946da5c695559954d895f5.svn-base <span style='color:#111;'> 1.45KB </span>","children":null,"spread":false}],"spread":false},{"title":"26","children":[{"title":"26d2ce83d71e204e34447e9a9c8912698ba9f059.svn-base <span style='color:#111;'> 1.57KB </span>","children":null,"spread":false}],"spread":false},{"title":"7b","children":[{"title":"7b62ff131620f5b44af84c397e50e1bcee65103c.svn-base <span style='color:#111;'> 23.29KB </span>","children":null,"spread":false}],"spread":false},{"title":"02","children":[{"title":"0224a2ce759fb4a30d96d0c763c4f80d4e4b9e09.svn-base <span style='color:#111;'> 466B </span>","children":null,"spread":false}],"spread":false},{"title":"b8","children":[{"title":"b83b35842cba9af9685dff65122c81e21a1a3cc4.svn-base <span style='color:#111;'> 1.27KB </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"wc.db <span style='color:#111;'> 44.00KB </span>","children":null,"spread":false},{"title":"tmp","children":null,"spread":false},{"title":"entries <span style='color:#111;'> 3B </span>","children":null,"spread":false},{"title":"format <span style='color:#111;'> 3B </span>","children":null,"spread":false}],"spread":false},{"title":"UnitTest_rtspCmd.h <span style='color:#111;'> 1.57KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspServer.c <span style='color:#111;'> 25.74KB </span>","children":null,"spread":false},{"title":"UnitTest_rtspRtp.h <span style='color:#111;'> 1.45KB </span>","children":null,"spread":false},{"title":"readme.txt <span style='color:#111;'> 63B </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明