asio C++ library

PrevUpHomeNext
basic_socket_streambuf::io_control (2 of 2 overloads)

Inherited from basic_socket.

Perform an IO control command on the socket.

template<
    typename IoControlCommand>
asio::error_code io_control(
    IoControlCommand & command,
    asio::error_code & ec);

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

Parameters

command

The IO control command to be performed on the socket.

ec

Set to indicate what error occurred, if any.

Example

Getting the number of bytes ready to read:

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

PrevUpHomeNext