Urdl C++ Library

PrevUpHomeNext
read_stream::async_open

Asynchronously opens the specified URL.

template<
    typename Handler>
void async_open(
    const url & u,
    Handler handler);

Parameters

u

The URL to open.

handler

The handler to be called when the open operation completes. Copies will be made of the handler as required. The function signature of the handler must be:

void handler(
  const boost::system::error_code& ec // Result of operation.
);

Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post().

Example

void open_handler(const boost::system::error_code& ec)
{
  if (!ec)
  {
    // Open succeeded.
  }
}
...
urdl::read_stream read_stream(io_service);
read_stream.async_open("http://www.boost.org/", open_handler);

PrevUpHomeNext