我们通过select来判断是否有监听的信息,如果有,自然去遍历。
那么遍历完后,是否需要清除这个有监听信息状态?
还是说FD_ISSET判断时他自己自动清除了?
网络编程中,select模型是否要重置fet_set状态
答案:2 悬赏:30
解决时间 2021-02-18 08:07
- 提问者网友:他是我的あ男人
- 2021-02-17 13:39
最佳答案
- 二级知识专家网友:狠傷凤凰
- 2021-02-17 14:49
select是需要重置set的:
int select(int maxfdp1, fd_set *readfds,
fd_set *writefds, fd_set *exceptfds,
struct timeval *tvptr);可以参阅《Advanced Programming in the UNIX Environment》,或者具体平台的manual。
通俗的说readfds, writefds, exceptfds即做“输入参数”,也做“输出参数”,就是传进去后会对应的fd_set被修改。
比如APUE上写到:
There are three possible return values from select.
1. A return value of −1 means that an error occurred. This can happen, for
example, if a signal is caught before any of the specified descriptors are ready.
In this case, none of the descriptor sets will be modified.
2. A return value of 0 means that no descriptors are ready. This happens if the
time limit expires before any of the descriptors are ready. When this happens,
all the descriptor sets will be zeroed out.
3. A positive return value specifies the number of descriptors that are ready. This
value is the sum of the descriptors ready in all three sets, so if the same
descriptor is ready to be read and written, it will be counted twice in the return
value. The only bits left on in the three descriptor sets are the bits
corresponding to the descriptors that are ready.
其中2.的最后一句就提到:如果select只是因为timeout到了,所有(readfds, writefds, exceptfds)都会被置为空。
int select(int maxfdp1, fd_set *readfds,
fd_set *writefds, fd_set *exceptfds,
struct timeval *tvptr);可以参阅《Advanced Programming in the UNIX Environment》,或者具体平台的manual。
通俗的说readfds, writefds, exceptfds即做“输入参数”,也做“输出参数”,就是传进去后会对应的fd_set被修改。
比如APUE上写到:
There are three possible return values from select.
1. A return value of −1 means that an error occurred. This can happen, for
example, if a signal is caught before any of the specified descriptors are ready.
In this case, none of the descriptor sets will be modified.
2. A return value of 0 means that no descriptors are ready. This happens if the
time limit expires before any of the descriptors are ready. When this happens,
all the descriptor sets will be zeroed out.
3. A positive return value specifies the number of descriptors that are ready. This
value is the sum of the descriptors ready in all three sets, so if the same
descriptor is ready to be read and written, it will be counted twice in the return
value. The only bits left on in the three descriptor sets are the bits
corresponding to the descriptors that are ready.
其中2.的最后一句就提到:如果select只是因为timeout到了,所有(readfds, writefds, exceptfds)都会被置为空。
全部回答
- 1楼网友:转身后的回眸
- 2021-02-17 15:06
我来回答: set rs = Server.CreateObject("Adbdb.RecordSet") rs.EOF 看是否到了结尾。 rs.BOF 看是否开始。 rs.MoveNext()
再看看别人怎么说的。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |