I think you need to buffer the incoming packets and process them everytime some new packets arrive.
Like this:
Code:
int rcv = recv(.. &buf...);
if(rcv > 0)
{
nw_buf.push_back(buf, rcv);
packethandler(nw_buf);
}
void packethandler(buf_type bf)
{
while(process_packet(bf) != TOO_SHORT)
{
packethandler(bf);
}
}
It's some ugly pseudo-code but i think it'll help you to get the gist of what i'm trying to say
Padmak