Other tcp stream examples? suggestion about asio examples... Re: usage of boost::asio::async_write and boost::asio::buffer
Hi All,
Thanks to Igor's pointing to streambuf I realized availability of stream
operations.
I think for many newbies, stream examples would be easier to
understand/reuse.
I found the very simple daytime_client and daytime_server examples useful.
(Examples could be reordered to start with simpler ones.)
Are there any other asio examples using streams?
If the contributors could add stream versions of chat server and client
examples that would be great.
I guess using streams is somewhat less efficient, is that correct? (since
you have more control on the buffer without streams.)
Best regards,
Ozgur (Oscar) Ozturk
www.DrOzturk.com
Phone: +1 (908) DROZGUR
i.e, +1 (908) 376-9487
On Tue, Jul 21, 2009 at 4:28 PM, Igor R
I tried to use the same string as buffer for both async_read_some and async_write
Who will allocate the buffer for the read operation? socket's async_read_some() doesn't know to do this alone.
I guess the string can not be treated as a mutable buffer, so maybe I should keep the original char * buffer for async_read_some and use the string only for outputting with async_write. Is that right? (or any other recommendation?)
Why wouldn't you use asio::streambuf? You've a set of functions that async.read/write from/to it, and it grows automatically. You can see relevant examples in asio docs. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thanks to Igor's pointing to streambuf I realized availability of stream operations. I think for many newbies, stream examples would be easier to understand/reuse.
You mean ip::tcp::iostream (note that it's unrelated to streambuf)? It's rather limited facility. You can use it for some very simple tasks, but if you need a scalable solution with multiple connection, timeouts etc, you'll unavoidably find yourself dealing with async. i/o.
participants (2)
-
Igor R
-
Ozgur Ozturk