中易网

网络编程中,select模型是否要重置fet_set状态

答案:2  悬赏:30  
解决时间 2021-02-18 08:07
我们通过select来判断是否有监听的信息,如果有,自然去遍历。

那么遍历完后,是否需要清除这个有监听信息状态?

还是说FD_ISSET判断时他自己自动清除了?
最佳答案
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)都会被置为空。
全部回答
我来回答: set rs = Server.CreateObject("Adbdb.RecordSet") rs.EOF 看是否到了结尾。 rs.BOF 看是否开始。 rs.MoveNext() 再看看别人怎么说的。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
红糖姜水可以用不绣锅煮吗
东方百合品种有哪些
西安外事学院专科
干瞪眼儿大王能当二出吗?
爱上直接领导怎么办
有在苏州三星电子工作过的吗?待遇怎么样 累
福州五一广场附近有没有地方照相?
别人送的浪琴男士表 想麻烦看看真假
冯哥副食经营部在哪里啊,我有事要去这个地方
楼梯间正压送风采用旁通阀手动,能实现余压控
左颈部皮下有个小硬物是什么啊?
下面哪种食物不是补充钙的良好途径
剑灵开学虽可怕的礼包领不了,我也登录游戏了
iphone语音打字显示不了中文,显示都是英语?
多读书可以提高语文成绩吗?读什么书?
推荐资讯
手机显示充电,指示灯也是亮的,但却充不进电
85后的人KTV唱什么歌好听
英雄联盟是人头好还是推塔好了?
出门不容易 (打一成语,掉尾格)灯谜大全及
he feels very tired.对very tired划线提问
求全套脊椎蛙动态图和短片!!++
我是成人,写字基础很差,我需要练习楷书还是
我做了伤残鉴定是九级,做工伤鉴定应该是几级
爱一个男生怎么爱
考中级会计师的从事会计工作满几年是怎么证明
力波有色合金精密铸造厂地址有知道的么?有点
请问雅马哈摩托车启动时为什么要拉风门,不拉
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?