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_stream_socket::wait (2 of 2 overloads)

Inherited from basic_socket.

Wait for the socket to become ready to read, ready to write, or to have pending error conditions.

void wait(
    wait_type w,
    boost::system::error_code & ec);

This function is used to perform a blocking wait for a socket to enter a ready to read, write or error condition state.



Specifies the desired socket state.


Set to indicate what error occurred, if any.


Waiting for a socket to become readable.

boost::asio::ip::tcp::socket socket(my_context);
boost::system::error_code ec;
socket.wait(boost::asio::ip::tcp::socket::wait_read, ec);