tags:

views:

980

answers:

1

What is the difference between calling boost::asio::ip::tcp::socket's read_some/write_some member functions and calling the boost::asio::read/boost::asio::write free functions?

More specifically:

Is there any benefit to using one over the other?

Why are both included in the library?

+5  A: 

read_some and write_some may return as soon as even a single byte has been transferred. As such you need to loop if you want to make sure you get all of the data - but this may be what you want.

The free functions are wrappers around read_some and write_some, and have different termination conditions depending on the overload. Typically they wait for the buffer to be fully transferred (or an error to occur, or in some overloads an explicit completion condition to occur)

bdonlan
But why include both?
plastic chris
They do different things (different termination conditions). I've edited my answer a bit, hopefully it's clearer now.
bdonlan