|
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