Thank you for the reply. I have been trying to get this to work but so far I cannot.


No matter what I do, the same amount of bytes is returned back to the client as was originally read. What am i doing wrong here?

Code:
  void handle_read(const boost::system::error_code& error,
      size_t bytes_transferred)
  {

        // data_ here == "thisisatest"
     
    if (!error)
    {
        data_[0] = 'X';                                  // this works
        char * cstr;
        string str (data_);
        str = str + "app";
        cstr = new char [str.size()+1];
        strcpy (cstr, str.c_str());

        // cstr  at this point == "Xhisisatestapp"
        // sizeof(cstr)  == 8   this is not correct


      boost::asio::async_write(socket_,
          boost::asio::buffer(cstr, sizeof(cstr)),          // sizeof(cstr) is not right here  I even try to hardcode this to 12 but it did not work either (only 10 bytes returned to client)
          boost::bind(&session::handle_write, this,
            boost::asio::placeholders::error));

            delete cstr;

// original code
//      boost::asio::async_write(socket_,
//          boost::asio::buffer(data_, bytes_transferred),
//          boost::bind(&session::handle_write, this,
//            boost::asio::placeholders::error));
    }
    else
    {
      delete this;
    }
  }