Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext
test::stream::lowest_layer_type

The type of the lowest layer.

Synopsis
using lowest_layer_type = stream;
Types

Name

Description

buffer_type

executor_type

The type of the executor associated with the object.

lowest_layer_type

The type of the lowest layer.

Member Functions

Name

Description

append

Appends a string to the pending input data.

async_read_some

Start an asynchronous read.

async_write_some

Start an asynchronous write.

buffer

Direct input buffer access.

clear

Clear the pending input area.

close

Close the stream.

close_remote

Close the other end of the stream.

connect

Establish a connection.

get_executor

Return the executor associated with the object.

lowest_layer

Get a reference to the lowest layer.

nread

Return the number of reads.

nwrite

Return the number of writes.

operator=

Move Assignment.

read_size

Set the maximum number of bytes returned by read_some.

read_some

Read some data from the stream.

str

Returns a string view representing the pending input data.

stream

Move Constructor.

Construct a stream.

write_size

Set the maximum number of bytes returned by write_some.

write_some

Write some data to the stream.

~stream

Destructor.

An instance of this class simulates a traditional socket, while also providing features useful for unit testing. Each endpoint maintains an independent buffer called the input area. Writes from one endpoint append data to the peer's pending input area. When an endpoint performs a read and data is present in the input area, the data is delivered to the blocking or asynchronous operation. Otherwise the operation is blocked or deferred until data is made available, or until the endpoints become disconnected.

These streams may be used anywhere an algorithm accepts a reference to a synchronous or asynchronous read or write stream. It is possible to use a test stream in a call to boost::asio::read_until, or in a call to http::async_write for example.

As with Boost.Asio I/O objects, a test::stream constructs with a reference to the boost::asio::io_context to use for handling asynchronous I/O. For asynchronous operations, the stream follows the same rules as a traditional asio socket with respect to how completion handlers for asynchronous operations are performed.

To facilitate testing, these streams support some additional features:

Thread Safety

Distinct objects: Safe.

Shared objects: Unsafe. The application must also ensure that all asynchronous operations are performed within the same implicit or explicit strand.

Concepts
Description

PrevUpHomeNext