Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio problems with async_read
From: Igor R (boost.lists_at_[hidden])
Date: 2011-08-08 09:08:12


> Here is how I call the function
>
> I have splitted it in two like this, because the protocol specifies a
> timeout pr. character and not pr. message
>
> std::vector<uint8_t> receive(boost::asio::io_service & io,
> boost::asio::serial_port & cctalk_port, size_t size){
>     std::vector<uint8_t> v;
>     size_t i = 0;
>
>     while( i < size ) {
>         std::vector<uint8_t> _v = receive(io, cctalk_port);
>         copy(_v.begin(), _v.end(), std::back_inserter(v));
>         i += _v.size();
>         cout << "Received: " << v.size() << "/" << size << endl;
>     }
>
>     return v;
>  }

Note that if poll_one() exits due to "out of work", you have to call
io_service::reset()
http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/reference/io_service/reset.html


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