Game Development Reference
In-Depth Information
return;
}
const int hdrSize = sizeof(u_long);
unsigned int newData = m_recvOfs + rc;
int processedData = 0;
while (newData > hdrSize)
{
packetSize = *(reinterpret_cast<u_long*>(m_recvBuf+m_recvBegin));
packetSize = ntohl(packetSize);
// we don
t have enough new data to grab the next packet
if (newData < packetSize)
break;
'
if (packetSize > MAX_PACKET_SIZE)
{
// prevent nasty buffer overruns!
HandleException();
return;
}
if (newData >= packetSize)
{
// we know how big the packet is...and we have the whole thing
shared_ptr<BinaryPacket> pkt(
GCC_NEW BinaryPacket(
&m_recvBuf[m_recvBegin+hdrSize], packetSize-hdrSize));
m_InList.push_back(pkt);
bPktRecieved = true;
processedData += packetSize;
newData -= packetSize;
m_recvBegin += packetSize;
}
}
g_pSocketManager->AddToInbound(rc);
m_recvOfs = newData;
if (bPktRecieved)
{
if (m_recvOfs == 0)
{
m_recvBegin = 0;
Search WWH ::




Custom Search