Jump to content
  • Advertisement
Sign in to follow this  
Dirge

Handling accept/recv calls

This topic is 4891 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

Recently I decided to clean up a network implementation I had done using DirectPlay and since it's officially in "Sunset" mode, I decided to shift over my API to pure WinSock (more for the learning experience). Now I hadn't used barebones WinSock in at least 2 years and came across a lot of familiar issues and idea's how to overcome them but nothing concrete, so naturally I started looking at how DirectPlay tackled them. For instance, there's the old Asynchronous/Non-blocking message issue. As far as I can tell, in DPlay it opens a seperate thread for recieving messages and accepting connections (one for each or a shared thread??), then calls the Message Handler Callback when a new event occurs. From all I've read the way a lot of people seem to solve this is through either using non-blocking calls and looping for the data, or using the win32 WSAAsyncSelect function, which I believe does the same thing as DPlay but uses the Windows Message Handler (through the PostMessage function). Obviously WSAAsyncSelect is not very portable (or annoying if you don't want to have to use the Windows Message Handler), and using the looped non-blocking calls seems to be pretty slow or error prone way to catch messages, so this seems to only leaves the custom thread/message handler technique as a viable option for me. So what I'm wondering is does all this sound about right or am I missing something here? Does anyone have any advice from how they've managed recv and accept calls in their own network setups? Thanks for any advice!

Share this post


Link to post
Share on other sites
Advertisement
Why would non-blocking calls be error-prone? The received messages will be buffered in the kernel until you ask for them.

Also, for portability, you can't beat plain old select().

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!