The code below works and works well for millions of messages on a daily basis. My question how/where does “msg” that is set up as a const vector get deleted if in fact that is what’s happening? I do not do anything in the completion handler to remove it.
Thanks
The typedef is set in the tcp_connection class. The method is also part of the class.
int tcp_connection::writeToSocketAsync(std::string sMsg)
{
typedef boost::shared_ptr<CharVec> CharVecPtr;
const std::vector<char> msg(sMsg.begin(), sMsg.end());
CharVecPtr tmsg = boost::make_shared<CharVec>(msg);
boost::asio::async_write(socket_,
boost::asio::buffer(*tmsg),
boost::asio::transfer_all(),
strand_.wrap(boost::bind(&tcp_connection::handle_write,
this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred)));
}