Hey,
I've been attempting to write a client/server app with boost now, so far it sends and receives but I can't seem to just read X bytes into a vector.
If I use the following code
vector<uint8_t> buf;
for (;;)
{
buf.resize(4);
boost::system::error_code error;
size_t len = socket.read_some(boost::asio::buffer(buf), error);
if (error == boost::asio::error::eof)
break; // Connection closed cleanly by peer.
else if (error)
throw boost::system::system_error(error); // Some other error.
}
And the packet is bigger then 4 bytes then it seems it keeps writing into those 4 bytes until the entire packet has been received, however I want it to fetch 4 bytes, then allow me to parse them, and then get the rest of the packet.
Can anyone provide me with a working example, or at least a pointer on how to make it work properly ?
Regards, Xeross