| Home | Libraries | People | FAQ | More

# boost::asio::buffered_stream< Stream > Class Template Reference

Inherits noncopyable.

Inheritance diagram for boost::asio::buffered_stream< Stream >:

List of all members.

## Detailed Description

### template<typename Stream>
class boost::asio::buffered_stream< Stream >

Adds buffering to the read- and write-related operations of a stream.

The buffered_stream class template can be used to add buffering to the synchronous and asynchronous read and write operations of a stream.

Thread Safety:
  Distinct objects: Safe.
  Shared objects: Unsafe.

Concepts:
  Async_Object, Async_Read_Stream, Async_Write_Stream, Error_Source, Stream, Sync_Read_Stream, Sync_Write_Stream.

## Public Types

typedef boost::remove_reference< Stream >::type | next_layer_type
| The type of the next layer.
typedef next_layer_type::lowest_layer_type | lowest_layer_type
| The type of the lowest layer.
typedef next_layer_type::error_type | error_type
| The type used for reporting errors.

## Public Member Functions

template<typename Arg>
| buffered_stream (Arg &a)
| Construct, passing the specified argument to initialise the next layer.
template<typename Arg>
| buffered_stream (Arg &a, std::size_t read_buffer_size, std::size_t write_buffer_size)
| Construct, passing the specified argument to initialise the next layer.
next_layer_type & | next_layer ()
| Get a reference to the next layer.
lowest_layer_type & | lowest_layer ()
| Get a reference to the lowest layer.
boost::asio::io_service & | io_service ()
| Get the io_service associated with the object.
void | close ()
| Close the stream.
template<typename Error_Handler>
void | close (Error_Handler error_handler)
| Close the stream.
std::size_t | flush ()
| Flush all data from the buffer to the next layer. Returns the number of bytes written to the next layer on the last write operation. Throws an exception on failure.
template<typename Error_Handler>
std::size_t | flush (Error_Handler error_handler)
| Flush all data from the buffer to the next layer. Returns the number of bytes written to the next layer on the last write operation, or 0 if an error occurred and the error handler did not throw.
template<typename Handler>
void | async_flush (Handler handler)
| Start an asynchronous flush.
template<typename Const_Buffers>
std::size_t | write_some (const Const_Buffers &buffers)
| Write the given data to the stream. Returns the number of bytes written. Throws an exception on failure.
template<typename Const_Buffers, typename Error_Handler>
std::size_t | write_some (const Const_Buffers &buffers, Error_Handler error_handler)
| Write the given data to the stream. Returns the number of bytes written, or 0 if an error occurred and the error handler did not throw.
template<typename Const_Buffers, typename Handler>
void | async_write_some (const Const_Buffers &buffers, Handler handler)
| Start an asynchronous write. The data being written must be valid for the lifetime of the asynchronous operation.
std::size_t | fill ()
| Fill the buffer with some data. Returns the number of bytes placed in the buffer as a result of the operation. Throws an exception on failure.
template<typename Error_Handler>
std::size_t | fill (Error_Handler error_handler)
| Fill the buffer with some data. Returns the number of bytes placed in the buffer as a result of the operation, or 0 if an error occurred and the error handler did not throw.
template<typename Handler>
void | async_fill (Handler handler)
| Start an asynchronous fill.
template<typename Mutable_Buffers>
std::size_t | read_some (const Mutable_Buffers &buffers)
| Read some data from the stream. Returns the number of bytes read. Throws an exception on failure.
template<typename Mutable_Buffers, typename Error_Handler>
std::size_t | read_some (const Mutable_Buffers &buffers, Error_Handler error_handler)
| Read some data from the stream. Returns the number of bytes read or 0 if an error occurred and the error handler did not throw an exception.
template<typename Mutable_Buffers, typename Handler>
void | async_read_some (const Mutable_Buffers &buffers, Handler handler)
| Start an asynchronous read. The buffer into which the data will be read must be valid for the lifetime of the asynchronous operation.
template<typename Mutable_Buffers>
std::size_t | peek (const Mutable_Buffers &buffers)
| Peek at the incoming data on the stream. Returns the number of bytes read. Throws an exception on failure.
template<typename Mutable_Buffers, typename Error_Handler>
std::size_t | peek (const Mutable_Buffers &buffers, Error_Handler error_handler)
| Peek at the incoming data on the stream. Returns the number of bytes read, or 0 if an error occurred and the error handler did not throw.
std::size_t | in_avail ()
| Determine the amount of data that may be read without blocking.
template<typename Error_Handler>
std::size_t | in_avail (Error_Handler error_handler)
| Determine the amount of data that may be read without blocking.

## Member Typedef Documentation

template<typename Stream>

typedef boost::remove_reference<Stream>::type boost::asio::buffered_stream< Stream >::next_layer_type

The type of the next layer.

template<typename Stream>

typedef next_layer_type::lowest_layer_type boost::asio::buffered_stream< Stream >::lowest_layer_type

The type of the lowest layer.

template<typename Stream>

typedef next_layer_type::error_type boost::asio::buffered_stream< Stream >::error_type

The type used for reporting errors.

## Constructor & Destructor Documentation

template<typename Stream>
template<typename Arg>

boost::asio::buffered_stream< Stream >::buffered_stream | ( | Arg & | a | ) | `[explicit]`

Construct, passing the specified argument to initialise the next layer.

template<typename Stream>
template<typename Arg>

boost::asio::buffered_stream< Stream >::buffered_stream | ( | Arg & | a,
|  | std::size_t | read_buffer_size,
|  | std::size_t | write_buffer_size |
| ) |  |  | `[explicit]`

Construct, passing the specified argument to initialise the next layer.

## Member Function Documentation

template<typename Stream>

next_layer_type& boost::asio::buffered_stream< Stream >::next_layer | ( |  | ) |

Get a reference to the next layer.

template<typename Stream>

lowest_layer_type& boost::asio::buffered_stream< Stream >::lowest_layer | ( |  | ) |

Get a reference to the lowest layer.

template<typename Stream>

boost::asio::io_service& boost::asio::buffered_stream< Stream >::io_service | ( |  | ) |

Get the io_service associated with the object.

template<typename Stream>

void boost::asio::buffered_stream< Stream >::close | ( |  | ) |

Close the stream.

template<typename Stream>
template<typename Error_Handler>

void boost::asio::buffered_stream< Stream >::close | ( | Error_Handler | error_handler | ) |

Close the stream.

template<typename Stream>

std::size_t boost::asio::buffered_stream< Stream >::flush | ( |  | ) |

Flush all data from the buffer to the next layer. Returns the number of bytes written to the next layer on the last write operation. Throws an exception on failure.

template<typename Stream>
template<typename Error_Handler>

std::size_t boost::asio::buffered_stream< Stream >::flush | ( | Error_Handler | error_handler | ) |

Flush all data from the buffer to the next layer. Returns the number of bytes written to the next layer on the last write operation, or 0 if an error occurred and the error handler did not throw.

template<typename Stream>
template<typename Handler>

void boost::asio::buffered_stream< Stream >::async_flush | ( | Handler | handler | ) |

Start an asynchronous flush.

template<typename Stream>
template<typename Const_Buffers>

std::size_t boost::asio::buffered_stream< Stream >::write_some | ( | const Const_Buffers & | buffers | ) |

Write the given data to the stream. Returns the number of bytes written. Throws an exception on failure.

template<typename Stream>
template<typename Const_Buffers, typename Error_Handler>

std::size_t boost::asio::buffered_stream< Stream >::write_some | ( | const Const_Buffers & | buffers,
|  | Error_Handler | error_handler |
| ) |  |  |

Write the given data to the stream. Returns the number of bytes written, or 0 if an error occurred and the error handler did not throw.

template<typename Stream>
template<typename Const_Buffers, typename Handler>

void boost::asio::buffered_stream< Stream >::async_write_some | ( | const Const_Buffers & | buffers,
|  | Handler | handler |
| ) |  |  |

Start an asynchronous write. The data being written must be valid for the lifetime of the asynchronous operation.

template<typename Stream>

std::size_t boost::asio::buffered_stream< Stream >::fill | ( |  | ) |

Fill the buffer with some data. Returns the number of bytes placed in the buffer as a result of the operation. Throws an exception on failure.

template<typename Stream>
template<typename Error_Handler>

std::size_t boost::asio::buffered_stream< Stream >::fill | ( | Error_Handler | error_handler | ) |

Fill the buffer with some data. Returns the number of bytes placed in the buffer as a result of the operation, or 0 if an error occurred and the error handler did not throw.

template<typename Stream>
template<typename Handler>

void boost::asio::buffered_stream< Stream >::async_fill | ( | Handler | handler | ) |

Start an asynchronous fill.

template<typename Stream>
template<typename Mutable_Buffers>

std::size_t boost::asio::buffered_stream< Stream >::read_some | ( | const Mutable_Buffers & | buffers | ) |

Read some data from the stream. Returns the number of bytes read. Throws an exception on failure.

template<typename Stream>
template<typename Mutable_Buffers, typename Error_Handler>

std::size_t boost::asio::buffered_stream< Stream >::read_some | ( | const Mutable_Buffers & | buffers,
|  | Error_Handler | error_handler |
| ) |  |  |

Read some data from the stream. Returns the number of bytes read or 0 if an error occurred and the error handler did not throw an exception.

template<typename Stream>
template<typename Mutable_Buffers, typename Handler>

void boost::asio::buffered_stream< Stream >::async_read_some | ( | const Mutable_Buffers & | buffers,
|  | Handler | handler |
| ) |  |  |

Start an asynchronous read. The buffer into which the data will be read must be valid for the lifetime of the asynchronous operation.

template<typename Stream>
template<typename Mutable_Buffers>

std::size_t boost::asio::buffered_stream< Stream >::peek | ( | const Mutable_Buffers & | buffers | ) |

Peek at the incoming data on the stream. Returns the number of bytes read. Throws an exception on failure.

template<typename Stream>
template<typename Mutable_Buffers, typename Error_Handler>

std::size_t boost::asio::buffered_stream< Stream >::peek | ( | const Mutable_Buffers & | buffers,
|  | Error_Handler | error_handler |
| ) |  |  |

Peek at the incoming data on the stream. Returns the number of bytes read, or 0 if an error occurred and the error handler did not throw.

template<typename Stream>

std::size_t boost::asio::buffered_stream< Stream >::in_avail | ( |  | ) |

Determine the amount of data that may be read without blocking.

template<typename Stream>
template<typename Error_Handler>

std::size_t boost::asio::buffered_stream< Stream >::in_avail | ( | Error_Handler | error_handler | ) |

Determine the amount of data that may be read without blocking.

| Copyright © 2003 - 2006 Christopher M. Kohlhoff