You should better learn the basics instead of developing a pserver.
Quote:
You should better learn the basics instead of developing a pserver.
She/He is right...And i think if you have coded the whole project yourself you would have known what`s the problem.Quote:
The client works perfectly, isn't coded by me(I'm developing p.server) ><
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);
}
}
What? Normally you got a TCPClient class which holds a socket, just do an async_read of like 4 bytes for the packet opcode and call your handler and let the handler read more from the socket if he needs it.Quote:
I think you need to buffer the incoming packets and process them everytime some new packets arrive.
Like this:
It's some ugly pseudo-code but i think it'll help you to get the gist of what i'm trying to sayCode: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); } }
Padmak