winsock select
生活随笔
收集整理的這篇文章主要介紹了
winsock select
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
MSDN中,有:
select
The select function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timeval* timeout );
Parameters
- nfds
- [in] Ignored. The nfds parameter is included only for compatibility with Berkeley sockets. readfds
- [in, out] Optional pointer to a set of sockets to be checked for readability. writefds
- [in, out] Optional pointer to a set of sockets to be checked for writability. exceptfds
- [in, out] Optional pointer to a set of sockets to be checked for errors. timeout
- [in] Maximum time for select to wait, provided in the form of a TIMEVAL structure. Set the timeout parameter to null for blocking operations.
?
?
?
http://hi.baidu.com/ytmayer/blog/item/602698667aa09422aa184cfd.html中,有:
struct timeval* timeout是select的超時時間,這個參數至關重要,它可以使select處于三種狀態。
第一,若將NULL以形參傳入,即不傳入時間結構,就是將select置于阻塞狀態,一定等到監視文件描述符集合中某個文件描述符發生變化為止;第二,若將時間值設為0秒0毫秒,就變成一個純粹的非阻塞函數,不管文件描述符是否有變化,都立刻返回繼續執行,文件無變化返回0,有變化返回一個正值;第三,timeout的值大于0,這就是等待的超時時間,即select在timeout時間內阻塞,超時時間之內有事件到來就返回了,否則在超時后不管怎樣一定返回,返回值同上述。
轉載于:https://www.cnblogs.com/WeRtogether/archive/2009/10/12/1581516.html
總結
以上是生活随笔為你收集整理的winsock select的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Silverlight中文件的生成操作与
- 下一篇: 手机主板多少钱啊?