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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With