Jump to content
  • Advertisement
Sign in to follow this  
nPawn

C# Select (non-blocking) tutorial?

This topic is 4429 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Anyone know of a tutorial for C# that discusses non-blocking via the Select function (instead of the Asynchronous method which i've read is a bad idea for games that send a lot of data). Seems there are plenty of asynchronous tutorials out there but i'm having a hard time finding one that uses Select non-blocking. Edit: Now i'm wondering if I should in fact go with asynchronous networking. This MSDN article: http://msdn.microsoft.com/msdnmag/issues/05/08/HighPerformanceSockets/default.aspx claims that asynchronous is the best mode to use, and NET 2.0 has some handy network logging available. I'm still a bit skeptical though, because doesn't asynchronous mode use the windows message pump? And it seems like that would get easily clogged if I was pushing a lot of packets through..? [Edited by - nPawn on July 6, 2006 5:03:25 PM]

Share this post


Link to post
Share on other sites
Advertisement
Asynchronous sockets are what you get when you call WSAAsyncSelect(), and it posts messages to your main message loop. Performance is awful.

That article is confusing, because it's talking about "asynchronous I/O" within the context of the .NET framework -- which is really implemented using I/O completion ports and overlapped I/O.

Remember: "Asynchronous I/O" != "Asynchronous Sockets".

Using the .NET sockets in asynchronous mode (based on I/O completion) is fine for performance and games.

Share this post


Link to post
Share on other sites
C#/.NET select will behave just like the general BSD style select() except that it replaces FDSETs with standard .NET enumerables, and ignores the traditional first parameter. Thus any common tutorial for select() (such as Beej's) will be fine to learn from; remembering the slight changes. I have some code floating around somewhere that uses it if you still run accross problems.

Share this post


Link to post
Share on other sites
I don't see what's confusing about that article, but anyways: Asynchronous I/O is implemented using I/O completion ports (when available), but that is certainly not guaranteed (and ealier versions of the framework didn't use IOCP in certain classes).

As far as Socket.Select goes, it uses the traditional select() function to perform its work.

Performance wise, asynchronous functions (Begin/End) will beat out select hands down if you need a great many sockets. Two things though: first of all, you will have two design around that functionality. The traditional approaches just don't work with Async I/O. Secondly, the performance gains for a small number of sockets is negligable at best, and the design requirements may cause you some headaches unless you have experience with threading/IOCP.

Share this post


Link to post
Share on other sites
The confusion is that nPawn confused "asynchronous I/O" with "asynchronous sockets" which are not the same thing.

In fact, what most people call "asynchronous I/O" is, technically, called overlapped I/O on Windows kernels, so the article is confusing by not using the underlying terminology.

Again: "asynchronous sockets" != "asynchronous I/O".

Also, "asynchronous sockets" != "asynchronous (overlapped) I/O on sockets".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!