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...
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@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users