Provides stream-oriented functionality using SSL. More...
#include <stream.hpp>
Public Types | |
typedef service_type::impl_type | impl_type |
The native implementation type of the stream. | |
typedef next_layer_type::lowest_layer_type | lowest_layer_type |
The type of the lowest layer. | |
typedef boost::remove_reference < Stream >::type | next_layer_type |
The type of the next layer. | |
typedef Service | service_type |
The type of the service that will be used to provide stream operations. | |
Public Member Functions | |
template<typename HandshakeHandler > | |
void | async_handshake (handshake_type type, HandshakeHandler handler) |
Start an asynchronous SSL handshake. | |
template<typename MutableBufferSequence , typename ReadHandler > | |
void | async_read_some (const MutableBufferSequence &buffers, ReadHandler handler) |
Start an asynchronous read. | |
template<typename ShutdownHandler > | |
void | async_shutdown (ShutdownHandler handler) |
Asynchronously shut down SSL on the stream. | |
template<typename ConstBufferSequence , typename WriteHandler > | |
void | async_write_some (const ConstBufferSequence &buffers, WriteHandler handler) |
Start an asynchronous write. | |
asio::io_service & | get_io_service () |
Get the io_service associated with the object. | |
void | handshake (handshake_type type) |
Perform SSL handshaking. | |
asio::error_code | handshake (handshake_type type, asio::error_code &ec) |
Perform SSL handshaking. | |
impl_type | impl () |
Get the underlying implementation in the native type. | |
std::size_t | in_avail () |
Determine the amount of data that may be read without blocking. | |
std::size_t | in_avail (asio::error_code &ec) |
Determine the amount of data that may be read without blocking. | |
asio::io_service & | io_service () |
lowest_layer_type & | lowest_layer () |
Get a reference to the lowest layer. | |
next_layer_type & | next_layer () |
Get a reference to the next layer. | |
template<typename MutableBufferSequence > | |
std::size_t | peek (const MutableBufferSequence &buffers) |
Peek at the incoming data on the stream. | |
template<typename MutableBufferSequence > | |
std::size_t | peek (const MutableBufferSequence &buffers, asio::error_code &ec) |
Peek at the incoming data on the stream. | |
template<typename MutableBufferSequence > | |
std::size_t | read_some (const MutableBufferSequence &buffers) |
Read some data from the stream. | |
template<typename MutableBufferSequence > | |
std::size_t | read_some (const MutableBufferSequence &buffers, asio::error_code &ec) |
Read some data from the stream. | |
void | shutdown () |
Shut down SSL on the stream. | |
asio::error_code | shutdown (asio::error_code &ec) |
Shut down SSL on the stream. | |
template<typename Arg , typename Context_Service > | |
stream (Arg &arg, basic_context< Context_Service > &context) | |
Construct a stream. | |
template<typename ConstBufferSequence > | |
std::size_t | write_some (const ConstBufferSequence &buffers) |
Write some data to the stream. | |
template<typename ConstBufferSequence > | |
std::size_t | write_some (const ConstBufferSequence &buffers, asio::error_code &ec) |
Write some data to the stream. | |
~stream () | |
Destructor. | |
Private Attributes | |
impl_type | impl_ |
The underlying native implementation. | |
Stream | next_layer_ |
The next layer. | |
service_type & | service_ |
The backend service implementation. |
Provides stream-oriented functionality using SSL.
The stream class template provides asynchronous and blocking stream-oriented functionality using SSL.
asio::io_service io_service; asio::ssl::context context(io_service, asio::ssl::context::sslv23); asio::ssl::stream<asio::ip::tcp::socket> sock(io_service, context);
Definition at line 58 of file stream.hpp.
typedef service_type::impl_type asio::ssl::stream< Stream, Service >::impl_type |
The native implementation type of the stream.
Definition at line 73 of file stream.hpp.
typedef next_layer_type::lowest_layer_type asio::ssl::stream< Stream, Service >::lowest_layer_type |
The type of the lowest layer.
Definition at line 67 of file stream.hpp.
typedef boost::remove_reference<Stream>::type asio::ssl::stream< Stream, Service >::next_layer_type |
The type of the next layer.
Definition at line 64 of file stream.hpp.
typedef Service asio::ssl::stream< Stream, Service >::service_type |
The type of the service that will be used to provide stream operations.
Definition at line 70 of file stream.hpp.
asio::ssl::stream< Stream, Service >::stream | ( | Arg & | arg, |
basic_context< Context_Service > & | context | ||
) | [inline, explicit] |
Construct a stream.
This constructor creates a stream and initialises the underlying stream object.
arg | The argument to be passed to initialise the underlying stream. |
context | The SSL context to be used for the stream. |
Definition at line 85 of file stream.hpp.
asio::ssl::stream< Stream, Service >::~stream | ( | ) | [inline] |
Destructor.
Definition at line 94 of file stream.hpp.
void asio::ssl::stream< Stream, Service >::async_handshake | ( | handshake_type | type, |
HandshakeHandler | handler | ||
) | [inline] |
Start an asynchronous SSL handshake.
This function is used to asynchronously perform an SSL handshake on the stream. This function call always returns immediately.
type | The type of handshaking to be performed, i.e. as a client or as a server. |
handler | The handler to be called when the handshake operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: void handler( const asio::error_code& error // Result of operation. ); |
Definition at line 212 of file stream.hpp.
void asio::ssl::stream< Stream, Service >::async_read_some | ( | const MutableBufferSequence & | buffers, |
ReadHandler | handler | ||
) | [inline] |
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.
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 asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes read. ); |
Definition at line 410 of file stream.hpp.
void asio::ssl::stream< Stream, Service >::async_shutdown | ( | ShutdownHandler | handler | ) | [inline] |
Asynchronously shut down SSL on the stream.
This function is used to asynchronously shut down SSL on the stream. This function call always returns immediately.
handler | The handler to be called when the handshake operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: void handler( const asio::error_code& error // Result of operation. ); |
Definition at line 256 of file stream.hpp.
void asio::ssl::stream< Stream, Service >::async_write_some | ( | const ConstBufferSequence & | buffers, |
WriteHandler | handler | ||
) | [inline] |
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.
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 asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes written. ); |
Definition at line 332 of file stream.hpp.
asio::io_service& asio::ssl::stream< Stream, Service >::get_io_service | ( | ) | [inline] |
Get the io_service associated with the object.
This function may be used to obtain the io_service object that the stream uses to dispatch handlers for asynchronous operations.
Definition at line 121 of file stream.hpp.
void asio::ssl::stream< Stream, Service >::handshake | ( | handshake_type | type | ) | [inline] |
Perform SSL handshaking.
This function is used to perform SSL handshaking on the stream. The function call will block until handshaking is complete or an error occurs.
type | The type of handshaking to be performed, i.e. as a client or as a server. |
asio::system_error | Thrown on failure. |
Definition at line 173 of file stream.hpp.
asio::error_code asio::ssl::stream< Stream, Service >::handshake | ( | handshake_type | type, |
asio::error_code & | ec | ||
) | [inline] |
Perform SSL handshaking.
This function is used to perform SSL handshaking on the stream. The function call will block until handshaking is complete or an error occurs.
type | The type of handshaking to be performed, i.e. as a client or as a server. |
ec | Set to indicate what error occurred, if any. |
Definition at line 190 of file stream.hpp.
impl_type asio::ssl::stream< Stream, Service >::impl | ( | ) | [inline] |
Get the underlying implementation in the native type.
This function may be used to obtain the underlying implementation of the context. This is intended to allow access to stream functionality that is not otherwise provided.
Definition at line 158 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::in_avail | ( | ) | [inline] |
Determine the amount of data that may be read without blocking.
This function is used to determine the amount of data, in bytes, that may be read from the stream without blocking.
asio::system_error | Thrown on failure. |
Definition at line 465 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::in_avail | ( | asio::error_code & | ec | ) | [inline] |
Determine the amount of data that may be read without blocking.
This function is used to determine the amount of data, in bytes, that may be read from the stream without blocking.
ec | Set to indicate what error occurred, if any. |
Definition at line 482 of file stream.hpp.
asio::io_service& asio::ssl::stream< Stream, Service >::io_service | ( | ) | [inline] |
(Deprecated: use get_io_service().) Get the io_service associated with the object. This function may be used to obtain the io_service object that the stream uses to dispatch handlers for asynchronous operations.
Definition at line 108 of file stream.hpp.
lowest_layer_type& asio::ssl::stream< Stream, Service >::lowest_layer | ( | ) | [inline] |
Get a reference to the lowest layer.
This function returns a reference to the lowest layer in a stack of stream layers.
Definition at line 147 of file stream.hpp.
next_layer_type& asio::ssl::stream< Stream, Service >::next_layer | ( | ) | [inline] |
Get a reference to the next layer.
This function returns a reference to the next layer in a stack of stream layers.
Definition at line 134 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::peek | ( | const MutableBufferSequence & | buffers | ) | [inline] |
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.
buffers | The buffers into which the data will be read. |
asio::system_error | Thrown on failure. |
Definition at line 429 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::peek | ( | const MutableBufferSequence & | buffers, |
asio::error_code & | ec | ||
) | [inline] |
Peek at the incoming data on the stream.
This function is used to peek at the incoming data on the stream, withoutxi removing it from the input queue. The function call will block until data has been read successfully or an error occurs.
buffers | The buffers into which the data will be read. |
ec | Set to indicate what error occurred, if any. |
Definition at line 450 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::read_some | ( | const MutableBufferSequence & | buffers | ) | [inline] |
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.
buffers | The buffers into which the data will be read. |
asio::system_error | Thrown on failure. |
Definition at line 355 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::read_some | ( | const MutableBufferSequence & | buffers, |
asio::error_code & | ec | ||
) | [inline] |
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.
buffers | The buffers into which the data will be read. |
ec | Set to indicate what error occurred, if any. |
Definition at line 380 of file stream.hpp.
void asio::ssl::stream< Stream, Service >::shutdown | ( | ) | [inline] |
Shut down SSL on the stream.
This function is used to shut down SSL on the stream. The function call will block until SSL has been shut down or an error occurs.
asio::system_error | Thrown on failure. |
Definition at line 224 of file stream.hpp.
asio::error_code asio::ssl::stream< Stream, Service >::shutdown | ( | asio::error_code & | ec | ) | [inline] |
Shut down SSL on the stream.
This function is used to shut down SSL on the stream. The function call will block until SSL has been shut down or an error occurs.
ec | Set to indicate what error occurred, if any. |
Definition at line 238 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::write_some | ( | const ConstBufferSequence & | buffers | ) | [inline] |
Write some data to 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.
buffers | The data to be written. |
asio::system_error | Thrown on failure. |
Definition at line 278 of file stream.hpp.
std::size_t asio::ssl::stream< Stream, Service >::write_some | ( | const ConstBufferSequence & | buffers, |
asio::error_code & | ec | ||
) | [inline] |
Write some data to 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.
buffers | The data to be written to the stream. |
ec | Set to indicate what error occurred, if any. |
Definition at line 303 of file stream.hpp.
impl_type asio::ssl::stream< Stream, Service >::impl_ [private] |
The underlying native implementation.
Definition at line 495 of file stream.hpp.
Stream asio::ssl::stream< Stream, Service >::next_layer_ [private] |
The next layer.
Definition at line 489 of file stream.hpp.
service_type& asio::ssl::stream< Stream, Service >::service_ [private] |
The backend service implementation.
Definition at line 492 of file stream.hpp.