Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] async_read and 100% CPU
From: Etienne Philip Pretorius (icewolfhunter_at_[hidden])
Date: 2009-06-30 15:24:38


Zachary Turner wrote:
> On Tue, Jun 30, 2009 at 1:46 PM, Etienne Philip
> Pretorius<icewolfhunter_at_[hidden]> wrote:
>> Michael Caisse wrote:
>>> Hi Etienne -
>>>
>>> Etienne Philip Pretorius wrote:
>>>> Hello list,
>>>>
>>>> Could someone please shed some light on this subject. It seems that me
>>>> read handler keeps on being called even when there has been no data
>>>> transferred...
>>>>
>>>> switch(error.value()) {
>>>> case boost::system::posix_error::success: {
>>>> c = new client();
>>>>
>>>> socket.async_receive(
>>>> boost::asio::buffer(
>>>> buffer
>>>> ),boost::bind(
>>>> &client::handle_read,
>>>> this,
>>>> boost::asio::placeholders::error,
>>>> boost::asio::placeholders::bytes_transferred
>>>> )
>>>> );
>>>
>>> Try changing this to use socket.async_read_some instead of async_receive.
>>>
>>> Regards -
>>> michael
>>>
>>>
>> :D, just tried it - still no luck.
>> I am invesigating if I am calling the buffer correctly. It seems that after
>> the call to async_receive/async_read_some that there is still data pending
>> for me to read... IE I never seem to get the data placed inside the
>> std::vector correctly.
>
> Are you saying that the handler is constantly getting called with
> bytes_transferred = 0?
>
yes
> What is contained inside your buffer object? If your buffer has a
> size of 0, then this seems like it would cause the problem.
>
yip, it has a size of 0. I hoped that the async receive would just
increase the size of the vector as it puts the contents into it, but
that is not happening.

> Also, do you mean that for a single invocation of async_receive(), the
> handler is getting called multiple times? Or that for each call to
> async_receive, the handler gets called once with bytes_transferred=0?
> Is there an error code?
The handler gets called once per invocation with bytes_transferred = 0
and error.value() = 0.

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
T


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