
What is packet_.buffer() and what do you do in recvHeader() ? Who calls recvMessage()?
packet_.buffer() returns the clients current buffer (buffer[512]) as char* This is the only place recvMessage is called --------------- void CClient::recvHeader(const boost::system::error_code& error) { if(!error && packet_.decode()) { boost::asio::async_read(socket_, boost::asio::buffer(packet_.buffer(), packet_.bodySize()), boost::bind(&CClient::recvMessage, shared_from_this(), boost::asio::placeholders::error) ); } else { disconnect(); } } In packet_.decode() the header is checked (through debugging I first notice the broken header before entering this function) and converted to the packet size and command, the size is used in packet_.bodySize(), which returns size_t *size