...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
(Deprecated: This wrapper is no longer needed; Asio linearizes scatter/gather I/O in ssl::stream.) Stream wrapper to improve write performance.
Defined in header <boost/beast/core/flat_stream.hpp>
template< class NextLayer> class flat_stream
Name |
Description |
---|---|
The type of the executor associated with the object. |
|
The type of the next layer. |
Name |
Description |
---|---|
Start an asynchronous read. |
|
Start an asynchronous write. |
|
flat_stream [constructor] |
|
Get the executor associated with the object. |
|
Get a reference to the next layer. |
|
Read some data from the stream. |
|
Write some data to the stream. |
|
~flat_stream [destructor] |
Destructor. |
This wrapper flattens writes for buffer sequences having length greater than
1 and total size below a predefined amount, using a dynamic memory allocation.
It is primarily designed to overcome a performance limitation of the current
version of net::ssl::stream
,
which does not use OpenSSL's scatter/gather interface for its low-level read
some and write some operations.
It is normally not necessary to use this class directly if you are already
using ssl_stream
.
The following examples shows how to use this class with the ssl stream that
comes with networking:
To use the flat_stream
template with SSL streams,
declare a variable of the correct type. Parameters passed to the constructor
will be forwarded to the next layer's constructor:
flat_stream<net::ssl::stream<ip::tcp::socket>> fs{ioc, ctx};
Alternatively you can write
ssl::stream<ip::tcp::socket> ss{ioc, ctx}; flat_stream<net::ssl::stream<ip::tcp::socket>&> fs{ss};
The resulting stream may be passed to any stream algorithms which operate on synchronous or asynchronous read or write streams, examples include:
net::read
, net::async_read
net::write
, net::async_write
net::read_until
, net::async_read_until
The stream may also be used as a template parameter in other stream wrappers, such as for websocket:
websocket::stream<flat_stream<net::ssl::stream<ip::tcp::socket>>> ws{ioc, ctx};
Type |
Description |
---|---|
|
The type representing the next layer, to which data will be read
and written during operations. For synchronous operations, the
type must support the SyncStream
concept. For asynchronous operations, the type must support the
AsyncStream concept. This type
will usually be some variation of |