|
Boost Users : |
Subject: Re: [Boost-users] [ASIO] async_read buffer: starting byte null
From: Matty Spatty (mattyspatty_at_[hidden])
Date: 2010-05-23 14:24:18
> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net