asio 0.3.7 Home | Reference | Tutorial | Examples | Design
Reference Class Hierarchy | Class Index | Member Index

Stream Class Reference

Inherits Async_Read_Stream, Async_Write_Stream, Sync_Read_Stream, and Sync_Write_Stream.

Inheritance diagram for Stream:

Inheritance graph
List of all members.

Detailed Description

Stream concept.

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


Public Types

typedef implementation_defined lowest_layer_type
 The type of the lowest layer in the stream.
typedef implementation_defined io_service_type
 The io_service type for this object.
typedef implementation_defined error_type
 The type used for reporting errors.
typedef implementation_defined io_service_type
 The io_service type for this object.
typedef implementation_defined error_type
 The type used for reporting errors.
typedef implementation_defined error_type
 The type used for reporting errors.
typedef implementation_defined error_type
 The type used for reporting errors.

Public Member Functions

lowest_layer_typelowest_layer ()
 Get a reference to the lowest layer.
template<typename Mutable_Buffers, typename Handler>
void async_read_some (const Mutable_Buffers &buffers, Handler handler)
 Start an asynchronous read.
io_service_typeio_service ()
 Get the io_service associated with the object.
template<typename Const_Buffers, typename Handler>
void async_write_some (const Const_Buffers &buffers, Handler handler)
 Start an asynchronous write.
io_service_typeio_service ()
 Get the io_service associated with the object.
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.
template<typename Const_Buffers>
std::size_t write_some (const Const_Buffers &buffers)
 Write the given data on the stream.
template<typename Const_Buffers, typename Error_Handler>
std::size_t write_some (const Const_Buffers &buffers, Error_Handler error_handler)
 Write the given data on the stream.


Member Typedef Documentation

typedef implementation_defined Stream::lowest_layer_type

The type of the lowest layer in the stream.

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.

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.

typedef implementation_defined Error_Source::error_type [inherited]

The type used for reporting errors.

typedef implementation_defined Error_Source::error_type [inherited]

The type used for reporting errors.


Member Function Documentation

lowest_layer_type& Stream::lowest_layer (  ) 

Get a reference to the lowest layer.

template<typename Mutable_Buffers, typename Handler>
void Async_Read_Stream::async_read_some ( const Mutable_Buffers buffers,
Handler  handler 
) [inherited]

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 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.

template<typename Const_Buffers, typename Handler>
void Async_Write_Stream::async_write_some ( const Const_Buffers buffers,
Handler  handler 
) [inherited]

Start an asynchronous write.

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

Parameters:
buffers The data to be written to the stream. 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 write operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void handler(
   const Async_Write_Stream::error_type& error, // Result of operation.
   std::size_t bytes_transferred                // Number of bytes written.
 ); 
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 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.

template<typename Mutable_Buffers>
std::size_t Sync_Read_Stream::read_some ( const Mutable_Buffers buffers  )  [inherited]

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 
) [inherited]

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  )  [inherited]

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 
) [inherited]

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 (  )  [inherited]

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  )  [inherited]

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.

template<typename Const_Buffers>
std::size_t Sync_Write_Stream::write_some ( const Const_Buffers buffers  )  [inherited]

Write the given data on the stream.

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

Parameters:
buffers The data to be written.
Returns:
The number of bytes written.
Exceptions:
Sync_Write_Stream::error_type Thrown on failure.

template<typename Const_Buffers, typename Error_Handler>
std::size_t Sync_Write_Stream::write_some ( const Const_Buffers buffers,
Error_Handler  error_handler 
) [inherited]

Write the given data on the stream.

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

Parameters:
buffers The data to be written.
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_Write_Stream::error_type& error // Result of operation.
 ); 
Returns:
The number of bytes written. Returns 0 if an error occurred and the error handler did not throw an exception.

asio 0.3.7 Home | Reference | Tutorial | Examples | Design