| Home | Libraries | People | FAQ | More

# Sync_Read_Stream Class Reference

Inherits Error_Source.

Inherited by Stream.

Inheritance diagram for Sync_Read_Stream:

List of all members.

## Detailed Description

Synchronous 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 | error_type
| The type used for reporting errors.

## Public Member Functions

template<typename Mutable_Buffers>
std::size_t | read_some (const Mutable_Buffers &buffers)
| Read some data from the stream.
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.
template<typename Mutable_Buffers>
std::size_t | peek (const Mutable_Buffers &buffers)
| Peek at the incoming data on the stream.
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.
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

typedef implementation_defined Error_Source::error_type `[inherited]`

The type used for reporting errors.

## Member Function Documentation

template<typename Mutable_Buffers>

std::size_t Sync_Read_Stream::read_some | ( | const Mutable_Buffers & | buffers | ) |

Read some data from the stream.

This function is used to read data from the stream. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.

Parameters:

  | buffers | The buffers into which the data will be read.

Returns:
  The number of bytes read.

Exceptions:

  | Sync_Read_Stream::error_type | Thrown on failure.

template<typename Mutable_Buffers, typename Error_Handler>

std::size_t Sync_Read_Stream::read_some | ( | const Mutable_Buffers & | buffers,
|  | Error_Handler | error_handler |
| ) |  |  |

Read some data from the stream.

This function is used to read data from the stream. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.

Parameters:

  | buffers | The buffers into which the data will be read.

  error_handler

  The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:

       void error_handler(
         const Sync_Read_Stream::error_type& error // Result of operation.
       );

Returns:
  The number of bytes read. Returns 0 if an error occurred and the error handler did not throw an exception.

template<typename Mutable_Buffers>

std::size_t Sync_Read_Stream::peek | ( | const Mutable_Buffers & | buffers | ) |

Peek at the incoming data on the stream.

This function is used to peek at the incoming data on the stream, without removing it from the input queue. The function call will block until data has been read successfully or an error occurs.

Parameters:

  | buffers | The buffers into which the data will be read.

Returns:
  The number of bytes read.

Exceptions:

  | Sync_Read_Stream::error_type | Thrown on failure.

template<typename Mutable_Buffers, typename Error_Handler>

std::size_t Sync_Read_Stream::peek | ( | const Mutable_Buffers & | buffers,
|  | Error_Handler | error_handler |
| ) |  |  |

Peek at the incoming data on the stream.

This function is used to peek at the incoming data on the stream, without removing it from the input queue. The function call will block until data has been read successfully or an error occurs.

Parameters:

  | buffers | The buffers into which the data will be read.

  error_handler

  The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:

       void error_handler(
         const Sync_Read_Stream::error_type& error // Result of operation.
       );

Returns:
  The number of bytes read. Returns 0 if an error occurred and the error handler did not throw an exception.

std::size_t Sync_Read_Stream::in_avail | ( |  | ) |

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

The function is used to determine the amount of data, in bytes, that may be read from the stream without blocking.

Returns:
  The number of bytes of data that can be read without blocking.

Exceptions:

  | Sync_Read_Stream::error_type | Thrown on failure.

template<typename Error_Handler>

std::size_t Sync_Read_Stream::in_avail | ( | Error_Handler | error_handler | ) |

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

The function is used to determine the amount of data, in bytes, that may be read from the stream without blocking.

Parameters:

  error_handler

  The handler to be called when an error occurs. Copies will be made of the handler as required. The equivalent function signature of the handler must be:

       void error_handler(
         const Sync_Read_Stream::error_type& error // Result of operation
       );

Returns:
  The number of bytes of data that can be read without blocking.

| Copyright © 2003 - 2006 Christopher M. Kohlhoff