Rading data from streambuf

View: New views
2 Messages — Rating Filter:   Alert me  

Rading data from streambuf

by Lloyd K L :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,
   How can we read data from a streambuf? I am using boost asio.
My code is as follows-

boost::asio::streambuf stream;
boost::asio::async_read_until(Socket,
          stream,string("\r\n"),
           boost::bind(&TCPConnection::HandleRead, shared_from_this(),
           boost::asio::placeholders::error));

....
....

How can i get the data from "stream" as a "char *buffer" or as a "string"

Thanks,
   Lloyd



______________________________________
Scanned and protected by Email scanner
_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: Rading data from streambuf

by Igor R :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Hi,  How can we read data from a streambuf? I am using boost asio.
> My code is as follows-
>
> boost::asio::streambuf stream;
> boost::asio::async_read_until(Socket,
>          stream,string("\r\n"),
>          boost::bind(&TCPConnection::HandleRead, shared_from_this(),
>          boost::asio::placeholders::error));
>
> ....
> ....
>
> How can i get the data from "stream" as a "char *buffer" or as a "string"

You can access it just like you access std::streambuf. Look at the example:
http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/reference/streambuf.html

Besides, you can use streambuf::data() member function to access the
character sequence directly. Look how it's done in
boost/asio/impl/read_util.ipp.
_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users