Will asio::ip::tcp::socket::read let me read all my data even if remote end is connected?

Looking at the documentation for this function: http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/reference/basic_str... I'm not entirely clear whether it will do what I want. Basically I'm going to be having a server send blocks of signal data (of unknown duration or length). I'd like the client to be able to read chunks of that until the remote end closes. So right now my API has the user pass in a memory buffer to fill along with a size and I repeatedly call socket::read to fill it up. What I'm curious about is if the server doesn't send a full block for the last block, and then closes the connection. Will this function still return whatever data it was able to read and then throw an exception on the next read? Or will it throw an exception on that last read, rendering the last bit of data inaccesible? Sean

What I'm curious about is if the server doesn't send a full block for the last block, and then closes the connection. Will this function still return whatever data it was able to read and then throw an exception on the next read? Or will it throw an exception on that last read, rendering the last bit of data inaccesible?
read() will return an error or throw an exception, depending on the function overload you use, but anyway you'll get all the data sent by the server.

How can I get all the data if it throws an exception during the last read?
On Mon, Mar 22, 2010 at 2:07 AM, Igor R
What I'm curious about is if the server doesn't send a full block for the last block, and then closes the connection. Will this function still return whatever data it was able to read and then throw an exception on the next read? Or will it throw an exception on that last read, rendering the last bit of data inaccesible?
read() will return an error or throw an exception, depending on the function overload you use, but anyway you'll get all the data sent by the server. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

How can I get all the data if it throws an exception during the last read?
Throwing an exception doesn't remove any data from the buffer you supply -- it's still there. Read also the following thread: http://article.gmane.org/gmane.comp.lib.boost.asio.user/3874

Awesome, thanks!
On Mon, Mar 22, 2010 at 7:39 AM, Igor R
How can I get all the data if it throws an exception during the last read?
Throwing an exception doesn't remove any data from the buffer you supply -- it's still there. Read also the following thread: http://article.gmane.org/gmane.comp.lib.boost.asio.user/3874 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Igor R
-
Sean McAllister