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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
basic_datagram_socket::io_control (2 of 2 overloads)

Inherited from basic_socket.

Perform an IO control command on the socket.

boost::system::error_code io_control(
    IoControlCommand & command,
    boost::system::error_code & ec);

This function is used to execute an IO control command on the socket.



The IO control command to be performed on the socket.


Set to indicate what error occurred, if any.


Getting the number of bytes ready to read:

boost::asio::ip::tcp::socket socket(io_service);
boost::asio::ip::tcp::socket::bytes_readable command;
boost::system::error_code ec;
socket.io_control(command, ec);
if (ec)
  // An error occurred.
std::size_t bytes_readable = command.get();