Boost logo

Boost Users :

Subject: Re: [Boost-users] asio::async_write, how to delete data after
From: ecyrbe (ecyrbe_at_[hidden])
Date: 2010-07-10 10:48:11


see the reference_counted example in the boost asio documentation. It's a
good start to allow dynamic buffer allocation and auto deletion when your
message is delivered...

2010/7/10 Matteo Lanzi <matteo.lanzi_at_[hidden]>

> Hi, I modified a little the echo server example and to build up a simple
> tcp server; basically what I do is:
>
>
>
> - Start the server in a thread
>
> - When a session is created I start async read
>
> - If my session receive a signal I write a data with async write
> function
>
> - Handle data written then start again async read ( otherwise the
> connection should be closed )
>
>
>
> I have some specific functions which prepare packets and then invoke the
> write method
>
>
>
> I would like to avoid static allocation of my buffer instead of dynamic
> one; for doing that I supposed to use shared_array<T>
>
> I can’t do that because the boost::asio::buffer, required by the write
> method, doesn’t seem to accept smart pointer.
>
>
>
> So my questions are:
>
> - Is there a common pattern to follow for preparing data and
> delete them after the delivery ?
>
> - Is it possible to use smart pointers with async_write ?
>
> - Is the async_write executed in another thread ? should I have
> concurrency problems if I would use an unique output buffer and clear it on
> the handle_write callback ?
>
>
>
> Thanks
>
> Matteo
>
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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