Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

transfer_exactly

Return a completion condition function object that indicates that a read or write operation should continue until an exact number of bytes has been transferred, or until an error occurs.

unspecified transfer_exactly(
    std::size_t size);

This function is used to create an object, of unspecified type, that meets CompletionCondition requirements.

Example

Reading until a buffer is full or contains exactly 64 bytes:

boost::array<char, 128> buf;
boost::system::error_code ec;
std::size_t n = boost::asio::read(
    sock, boost::asio::buffer(buf),
    boost::asio::transfer_exactly(64), ec);
if (ec)
{
  // An error occurred.
}
else
{
  // n == 64
}
Requirements

Header: boost/asio/completion_condition.hpp

Convenience header: boost/asio.hpp


PrevUpHomeNext