| Home | Libraries | People | FAQ | More

# Async_Read_Stream Class Reference

Inherits Async_Object, and Error_Source.

Inherited by Stream.

Inheritance diagram for Async_Read_Stream:

List of all members.

## Detailed Description

Asynchronous read stream concept.

Implemented By:
  boost::asio::basic_stream_socket
  boost::asio::buffered_read_stream
  boost::asio::buffered_write_stream
  boost::asio::buffered_stream
  boost::asio::ssl::stream

## Public Types

typedef implementation_defined | io_service_type
| The io_service type for this object.
typedef implementation_defined | error_type
| The type used for reporting errors.

## Public Member Functions

template<typename Mutable_Buffers, typename Handler>
void | async_read_some (const Mutable_Buffers &buffers, Handler handler)
| Start an asynchronous read.
io_service_type & | io_service ()
| Get the io_service associated with the object.

## Member Typedef Documentation

typedef implementation_defined Async_Object::io_service_type`[inherited]`

The io_service type for this object.

typedef implementation_defined Error_Source::error_type`[inherited]`

The type used for reporting errors.

## Member Function Documentation

template<typename Mutable_Buffers, typename Handler>

void Async_Read_Stream::async_read_some | ( | const Mutable_Buffers & | buffers,
|  | Handler | handler |
| ) |  |  |

Start an asynchronous read.

This function is used to asynchronously read one or more bytes of data from the stream. The function call always returns immediately.

Parameters:

  | buffers | The buffers into which the data will be read. Although the buffers object may be copied as necessary, ownership of the underlying buffers is retained by the caller, which must guarantee that they remain valid until the handler is called.
  | handler | The handler to be called when the read operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
       void handler(
         const Async_Read_Stream::error_type& error, // Result of operation.
         std::size_t bytes_transferred               // Number of bytes read.
       );
  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().

io_service_type& Async_Object::io_service | ( |  | ) | `[inherited]`

Get the io_service associated with the object.

This function may be used to obtain the io_service object that the object uses to dispatch handlers for asynchronous operations.

Returns:
  A reference to the io_service object that the object will use to dispatch handlers. Ownership is not transferred to the caller.

| Copyright © 2003 - 2006 Christopher M. Kohlhoff