开发者

Can C# socket.select return more than one sockets

I won开发者_StackOverflow社区der if Socket.Select from .Net can return an IList of two or more elements. So far in my testing, they always return one element after the other (Socket.Select is inside a loop). May I know what kind of testing that you did to be able to return two or more elements?


Using the "can read" example here but it applies to the other IList parameters ("can write", "has error") as well:

Socket.Select returns as soon as one of the supplied sockets has data available for reading. This means that if you enter Socket.Select before data has arrived on multiple sockets, it would typically return when only one socket has data available (if you think of it this way, why would it wait for another to have data available?).

To try out the case where multiple sockets can read, you can simply add a Thread.Sleep before your Socket.Select with a large enough delay to allow two sending processes to both send their data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜