Unless I'm missing something it looks like you are passing zero-length vector to the buffer() function.
From asio docs this call is equivalent to:
mutable_buffers_1( data.size() ? &data[0] : 0, min(data.size() * sizeof(PodType), max_size_in_bytes)); ,where the data.size() = read_buffer_.size() i.e. zero for empty vector. You might try vector::resize(15) or just a size-taking constructor. Cheers, -- Nikolai
Trying to limit number of bytes transferred to at least 15 bytes before async_read call back I have got callbacks with sizes: 0,1,2,3,4 and 5 (so total indeed 15) But I was expecting only single callback with size 15.
How I can fix the issue?
Thanks Vlad.
linux suse 2.6.16 boost 1.39 gcc 4.1.2
//boost asio stripped part.
BufferSize=1000; class test{
vector<char> read_buffer_; boost::asio::ip::tcp::socket socket_; //socket was inited correctly.
test() { read_buffer_.reserve(BufferSize); }
void handle_connect( const boost::system::error_code& err, boost::asio::ip::tcp::resolver::iterator endpoint_iterator ) { if (!err) { boost::asio::async_read(socket_,boost::asio::buffer(read_buffer_, BufferSize), //requested at least 15 bytes!! boost::asio::transfer_at_least(15), boost::bind(&test::handle_read, this, boost::asio::placeholders::error)); } else { cerr<
void handle_read( const boost::system::error_code& err) { if (!err) { //+++++++++++++++++++++++++++ //expecting to get at least 15! //But have not get those. //+++++++++++++++++++++++++++ cerr<<"Got:"<
};
=============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ===============================================================================
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users