Handling accept/recv calls
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!
"Artificial Intelligence: the art of making computers that behave like the ones in movies."www.CodeFortress.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement