# Tricks and stuff for Non-Blocking UDP?

## Recommended Posts

GeekPlusPlus    124
Hello, This is all for C++ on a windows box. I was just wondering if there were any standard rules, tricks, checks I need to do when using a non blocking UDP setup for a rather lage multi player game. My main processing function is as follows: I know you're missing a lot of the classes, but there's a lot too it to post. This is the heart of it all, if you have any suggestions I'm listening. =)
void CConnectionManager::Process(CPacketHandler* pPacketHandler)
{

const timeval timeWait = {0, 0};

{

m_pPacketBuffer->SetLength(iLength - sizeof(CPacket));

if(iLength >= sizeof(CPacket))
pPacketHandler->HandlePacket(m_pPacketBuffer);
}

return;
}

Thanks,

##### Share on other sites
cbenoi1    484
> if you have any suggestions

You don't really need the select() here because you can get the information from recvfrom()'s returning value along with WSAGetLastError(). 0 for no data, SOCKET_ERROR for an error.

> when using a non blocking UDP setup for a rather
> large multi player game

Lemme guess.... a MMORPG? {large grin}

Handling a very large number of users can only be achieved using IOCP on Windows NT/2K/XP-class machines. Here is some code to start you up on this path:

Hope this helps.

http://pages.infinit.net/cbenoi1/iocp_udp.zip

-cb