I\'m adding HTTPS support to code that does input and output using boost tcp::iostream (acting as an HTTP server).
I\'ve found examples (and have a working toy HTTPS
I think what you want to do is use stream buffers (asio::streambuf)
Then you can do something like (untested code written on the fly follows):
boost::asio::streambuf msg;
std::ostream msg_stream(&msg);
msg_stream << "hello world";
msg_stream.flush();
boost::asio::write(stream, msg);
Similarly your read/receive side can read into a stream buffer in conjunction with std::istream so you can process your input using various stream functions/operators.
Asio reference for streambuf
Another note is I think you should check out the asio tutorials/examples. Once you do you'll probably want to change your code to work asynchronously rather than the synchronous example you're showing above.