Sign in to follow this  

Handling accept/recv calls

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this