Boost logo

Boost Users :

Subject: Re: [Boost-users] usage of boost::asio::async_write and boost::asio::buffer
From: Igor R (boost.lists_at_[hidden])
Date: 2009-07-21 07:14:04


> boost::asio::async_write(socket_,
>               boost::asio::buffer(replyString, replyString.size()),
>               boost::bind(&session::handle_write, this,
>                 boost::asio::placeholders::error));
>
> I generate the replyString to have results from my database query separated
> with ^ signs (which is used to tokenize the replyString on the client
> side...)
>
>             string replyString="1^";

boost::asio::buffer does not copy your local string, so the string
vanishes before the actual async. write takes place.
By the way, if you wish to send the whole string, you don't have to
pass a size: boost::asio::buffer(replyString) - but the string must be
alive until the completion handler is called.


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