Boost logo

Boost Users :

Subject: Re: [Boost-users] asio UDP message packet loss even on localhost?
From: Michael Caisse (boost_at_[hidden])
Date: 2010-10-22 11:21:03


On 10/22/2010 8:12 AM, Ákos Maróy wrote:
> On 22/10/10 17:08, Michael Caisse wrote:
>> On 10/22/2010 7:53 AM, Ákos Maróy wrote:
>>> actually an asio::buffer object is created in send(), which copies the
>>> contents over. this is the same pattern as used in the same sample code
>>> quoted above.
>> This is a common error. The asio::buffer simply wraps the memory and
>> provides a starting location and size. You still must manage the memory.
>>
>> <http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/reference/buffer.html>
> thanks for pointing this out. it would be nice to get rid of this wrong
> pattern in the 'official' example code too :)

The code examples do this correctly. It uses a private data member in
the class named data_. The pattern uses bind and shared_from_this in the
handlers to ensure lifetime. That is the correct way.

You may find my boostcon10 slides useful. Ownership of memory buffers is
part of the proactor model.

<http://www.objectmodelingdesigns.com/boostcon10/>
<http://www.blip.tv/file/4171562/>

michael

-- 
----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com

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