Boost logo

Boost Users :

Subject: [Boost-users] asio::async_write, how to delete data after
From: Matteo Lanzi (matteo.lanzi_at_[hidden])
Date: 2010-07-09 19:49:33


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 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