亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問關于select函數的操作程序?

請問關于select函數的操作程序?

郎朗坤 2019-09-20 18:14:22
select函數的操作程序
查看完整描述

4 回答

?
慕容708150

TA貢獻1831條經驗 獲得超4個贊

下面具體解釋:
#include <sys/types.h>
#include <sys/times.h>
#include <sys/select.h>
int select(nfds, readfds, writefds, exceptfds, timeout)
int nfds;
fd_set *readfds, *writefds, *exceptfds;
struct timeval *timeout;
nfds:select監視的文件句柄數,視進程中打開的文件數而定,一般設為你要監視各文件
中的最大文件號加一。(注:nfds并非一定表示監視的文件句柄數。官方文檔僅指出nfds is the highest-numbered file descriptor in any of the three sets, plus 1. (可在linux環境中通過man select命令查得))
readfds:select監視的可讀文件句柄集合。
writefds: select監視的可寫文件句柄集合。
exceptfds:select監視的異常文件句柄集合。
timeout:本次select()的超時結束時間。(見/usr/sys/select.h,可精確至百萬分之一秒!)
當readfds或writefds中映象的文件可讀或可寫或超時,本次select()
就結束返回。程序員利用一組系統提供的宏在select()結束時便可判
斷哪一文件可讀或可寫,對Socket編程特別有用的就是readfds。





查看完整回答
反對 回復 2019-09-22
  • 4 回答
  • 0 關注
  • 549 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號