Realistic 3D camera system
3D camera system components
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
asio::ssl::stream< Stream > Class Template Reference

Provides stream-oriented functionality using SSL. More...

#include <stream.hpp>

Inheritance diagram for asio::ssl::stream< Stream >:
asio::ssl::stream_base asio::detail::noncopyable

Classes

struct  impl_struct
 Structure for use with deprecated impl_type. More...
 

Public Types

typedef SSL * native_handle_type
 The native handle type of the SSL stream. More...
 
typedef impl_structimpl_type
 (Deprecated: Use native_handle_type.) The underlying implementation type. More...
 
typedef remove_reference< Stream >::type next_layer_type
 The type of the next layer. More...
 
typedef next_layer_type::lowest_layer_type lowest_layer_type
 The type of the lowest layer. More...
 
- Public Types inherited from asio::ssl::stream_base
enum  handshake_type { client, server }
 Different handshake types. More...
 

Public Member Functions

template<typename Arg >
 stream (Arg &arg, context &ctx)
 Construct a stream. More...
 
 ~stream ()
 Destructor. More...
 
asio::io_serviceget_io_service ()
 Get the io_service associated with the object. More...
 
native_handle_type native_handle ()
 Get the underlying implementation in the native type. More...
 
impl_type impl ()
 
const next_layer_typenext_layer () const
 Get a reference to the next layer. More...
 
next_layer_typenext_layer ()
 Get a reference to the next layer. More...
 
lowest_layer_typelowest_layer ()
 Get a reference to the lowest layer. More...
 
const lowest_layer_typelowest_layer () const
 Get a reference to the lowest layer. More...
 
void set_verify_mode (verify_mode v)
 Set the peer verification mode. More...
 
asio::error_code set_verify_mode (verify_mode v, asio::error_code &ec)
 Set the peer verification mode. More...
 
void set_verify_depth (int depth)
 Set the peer verification depth. More...
 
asio::error_code set_verify_depth (int depth, asio::error_code &ec)
 Set the peer verification depth. More...
 
template<typename VerifyCallback >
void set_verify_callback (VerifyCallback callback)
 Set the callback used to verify peer certificates. More...
 
template<typename VerifyCallback >
asio::error_code set_verify_callback (VerifyCallback callback, asio::error_code &ec)
 Set the callback used to verify peer certificates. More...
 
void handshake (handshake_type type)
 Perform SSL handshaking. More...
 
asio::error_code handshake (handshake_type type, asio::error_code &ec)
 Perform SSL handshaking. More...
 
template<typename ConstBufferSequence >
void handshake (handshake_type type, const ConstBufferSequence &buffers)
 Perform SSL handshaking. More...
 
template<typename ConstBufferSequence >
asio::error_code handshake (handshake_type type, const ConstBufferSequence &buffers, asio::error_code &ec)
 Perform SSL handshaking. More...
 
template<typename HandshakeHandler >
 ASIO_INITFN_RESULT_TYPE (HandshakeHandler, void(asio::error_code)) async_handshake(handshake_type type
 Start an asynchronous SSL handshake. More...
 
 ASIO_MOVE_ARG (HandshakeHandler) handler)
 
template<typename ConstBufferSequence , typename BufferedHandshakeHandler >
 ASIO_INITFN_RESULT_TYPE (BufferedHandshakeHandler, void(asio::error_code, std::size_t)) async_handshake(handshake_type type
 Start an asynchronous SSL handshake. More...
 
const ConstBufferSequence ASIO_MOVE_ARG (BufferedHandshakeHandler) handler)
 
void shutdown ()
 Shut down SSL on the stream. More...
 
asio::error_code shutdown (asio::error_code &ec)
 Shut down SSL on the stream. More...
 
template<typename ShutdownHandler >
 ASIO_INITFN_RESULT_TYPE (ShutdownHandler, void(asio::error_code)) async_shutdown(ASIO_MOVE_ARG(ShutdownHandler) handler)
 Asynchronously shut down SSL on the stream. More...
 
template<typename ConstBufferSequence >
std::size_t write_some (const ConstBufferSequence &buffers)
 Write some data to the stream. More...
 
template<typename ConstBufferSequence >
std::size_t write_some (const ConstBufferSequence &buffers, asio::error_code &ec)
 Write some data to the stream. More...
 
template<typename ConstBufferSequence , typename WriteHandler >
 ASIO_INITFN_RESULT_TYPE (WriteHandler, void(asio::error_code, std::size_t)) async_write_some(const ConstBufferSequence &buffers
 Start an asynchronous write. More...
 
 ASIO_MOVE_ARG (WriteHandler) handler)
 
template<typename MutableBufferSequence >
std::size_t read_some (const MutableBufferSequence &buffers)
 Read some data from the stream. More...
 
template<typename MutableBufferSequence >
std::size_t read_some (const MutableBufferSequence &buffers, asio::error_code &ec)
 Read some data from the stream. More...
 
template<typename MutableBufferSequence , typename ReadHandler >
 ASIO_INITFN_RESULT_TYPE (ReadHandler, void(asio::error_code, std::size_t)) async_read_some(const MutableBufferSequence &buffers
 Start an asynchronous read. More...
 
 ASIO_MOVE_ARG (ReadHandler) handler)
 

Public Attributes

const ConstBufferSequence & buffers
 

Additional Inherited Members

- Protected Member Functions inherited from asio::ssl::stream_base
 ~stream_base ()
 Protected destructor to prevent deletion through this type. More...
 

Detailed Description

template<typename Stream>
class asio::ssl::stream< Stream >

Provides stream-oriented functionality using SSL.

The stream class template provides asynchronous and blocking stream-oriented functionality using SSL.

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.
Example
To use the SSL stream template with an ip::tcp::socket, you would write:
Concepts:
AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.

Definition at line 73 of file stream.hpp.

Member Typedef Documentation

template<typename Stream>
typedef impl_struct* asio::ssl::stream< Stream >::impl_type

(Deprecated: Use native_handle_type.) The underlying implementation type.

Definition at line 88 of file stream.hpp.

template<typename Stream>
typedef next_layer_type::lowest_layer_type asio::ssl::stream< Stream >::lowest_layer_type

The type of the lowest layer.

Definition at line 94 of file stream.hpp.

template<typename Stream>
typedef SSL* asio::ssl::stream< Stream >::native_handle_type

The native handle type of the SSL stream.

Definition at line 79 of file stream.hpp.

template<typename Stream>
typedef remove_reference<Stream>::type asio::ssl::stream< Stream >::next_layer_type

The type of the next layer.

Definition at line 91 of file stream.hpp.

Constructor & Destructor Documentation

template<typename Stream>
template<typename Arg >
asio::ssl::stream< Stream >::stream ( Arg &  arg,
context ctx 
)
inline

Construct a stream.

This constructor creates a stream and initialises the underlying stream object.

Parameters
argThe argument to be passed to initialise the underlying stream.
ctxThe SSL context to be used for the stream.

Definition at line 106 of file stream.hpp.

template<typename Stream>
asio::ssl::stream< Stream >::~stream ( )
inline

Destructor.

Definition at line 114 of file stream.hpp.

Member Function Documentation

template<typename Stream>
template<typename HandshakeHandler >
asio::ssl::stream< Stream >::ASIO_INITFN_RESULT_TYPE ( HandshakeHandler  ,
void(asio::error_code  
)

Start an asynchronous SSL handshake.

This function is used to asynchronously perform an SSL handshake on the stream. This function call always returns immediately.

Parameters
typeThe type of handshaking to be performed, i.e. as a client or as a server.
handlerThe 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.
);
template<typename Stream>
template<typename ConstBufferSequence , typename BufferedHandshakeHandler >
asio::ssl::stream< Stream >::ASIO_INITFN_RESULT_TYPE ( BufferedHandshakeHandler  ,
void(asio::error_code, std::size_t)   
)

Start an asynchronous SSL handshake.

This function is used to asynchronously perform an SSL handshake on the stream. This function call always returns immediately.

Parameters
typeThe type of handshaking to be performed, i.e. as a client or as a server.
buffersThe buffered data to be reused for the handshake. 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.
handlerThe 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.
std::size_t bytes_transferred // Amount of buffers used in handshake.
);
template<typename Stream>
template<typename ShutdownHandler >
asio::ssl::stream< Stream >::ASIO_INITFN_RESULT_TYPE ( ShutdownHandler  ,
void(asio::error_code  
)
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.

Parameters
handlerThe 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 543 of file stream.hpp.

template<typename Stream>
template<typename ConstBufferSequence , typename WriteHandler >
asio::ssl::stream< Stream >::ASIO_INITFN_RESULT_TYPE ( WriteHandler  ,
void(asio::error_code, std::size_t)   
) const

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
buffersThe 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.
handlerThe 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.
);
Note
The async_write_some operation may not transmit all of the data to the peer. Consider using the asio::async_write function if you need to ensure that all data is written before the blocking operation completes.
template<typename Stream>
template<typename MutableBufferSequence , typename ReadHandler >
asio::ssl::stream< Stream >::ASIO_INITFN_RESULT_TYPE ( ReadHandler  ,
void(asio::error_code, std::size_t)   
) const

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
buffersThe 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.
handlerThe 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.
);
Note
The async_read_some operation may not read all of the requested number of bytes. Consider using the asio::async_read function if you need to ensure that the requested amount of data is read before the asynchronous operation completes.
template<typename Stream>
asio::ssl::stream< Stream >::ASIO_MOVE_ARG ( HandshakeHandler  )
inline

Definition at line 444 of file stream.hpp.

template<typename Stream>
const ConstBufferSequence asio::ssl::stream< Stream >::ASIO_MOVE_ARG ( BufferedHandshakeHandler  )
inline

Definition at line 485 of file stream.hpp.

template<typename Stream>
asio::ssl::stream< Stream >::ASIO_MOVE_ARG ( WriteHandler  )
inline

Definition at line 635 of file stream.hpp.

template<typename Stream>
asio::ssl::stream< Stream >::ASIO_MOVE_ARG ( ReadHandler  )
inline

Definition at line 727 of file stream.hpp.

template<typename Stream>
asio::io_service& asio::ssl::stream< Stream >::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.

Returns
A reference to the io_service object that stream will use to dispatch handlers. Ownership is not transferred to the caller.

Definition at line 126 of file stream.hpp.

template<typename Stream>
void asio::ssl::stream< Stream >::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.

Parameters
typeThe type of handshaking to be performed, i.e. as a client or as a server.
Exceptions
asio::system_errorThrown on failure.

Definition at line 360 of file stream.hpp.

template<typename Stream>
asio::error_code asio::ssl::stream< Stream >::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.

Parameters
typeThe type of handshaking to be performed, i.e. as a client or as a server.
ecSet to indicate what error occurred, if any.

Definition at line 377 of file stream.hpp.

template<typename Stream>
template<typename ConstBufferSequence >
void asio::ssl::stream< Stream >::handshake ( handshake_type  type,
const ConstBufferSequence &  buffers 
)
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.

Parameters
typeThe type of handshaking to be performed, i.e. as a client or as a server.
buffersThe buffered data to be reused for the handshake.
Exceptions
asio::system_errorThrown on failure.

Definition at line 397 of file stream.hpp.

template<typename Stream>
template<typename ConstBufferSequence >
asio::error_code asio::ssl::stream< Stream >::handshake ( handshake_type  type,
const ConstBufferSequence &  buffers,
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.

Parameters
typeThe type of handshaking to be performed, i.e. as a client or as a server.
buffersThe buffered data to be reused for the handshake.
ecSet to indicate what error occurred, if any.

Definition at line 417 of file stream.hpp.

template<typename Stream>
impl_type asio::ssl::stream< Stream >::impl ( )
inline

(Deprecated: Use native_handle().) 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 167 of file stream.hpp.

template<typename Stream>
lowest_layer_type& asio::ssl::stream< Stream >::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.

Returns
A reference to the lowest layer in the stack of stream layers. Ownership is not transferred to the caller.

Definition at line 206 of file stream.hpp.

template<typename Stream>
const lowest_layer_type& asio::ssl::stream< Stream >::lowest_layer ( ) const
inline

Get a reference to the lowest layer.

This function returns a reference to the lowest layer in a stack of stream layers.

Returns
A reference to the lowest layer in the stack of stream layers. Ownership is not transferred to the caller.

Definition at line 219 of file stream.hpp.

template<typename Stream>
native_handle_type asio::ssl::stream< Stream >::native_handle ( )
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 context functionality that is not otherwise provided.

Example
The native_handle() function returns a pointer of type SSL* that is suitable for passing to functions such as SSL_get_verify_result and SSL_get_peer_certificate:
// ... establish connection and perform handshake ...
if (X509* cert = SSL_get_peer_certificate(sock.native_handle()))
{
if (SSL_get_verify_result(sock.native_handle()) == X509_V_OK)
{
// ...
}
}

Definition at line 155 of file stream.hpp.

template<typename Stream>
const next_layer_type& asio::ssl::stream< Stream >::next_layer ( ) const
inline

Get a reference to the next layer.

This function returns a reference to the next layer in a stack of stream layers.

Returns
A reference to the next layer in the stack of stream layers. Ownership is not transferred to the caller.

Definition at line 180 of file stream.hpp.

template<typename Stream>
next_layer_type& asio::ssl::stream< Stream >::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.

Returns
A reference to the next layer in the stack of stream layers. Ownership is not transferred to the caller.

Definition at line 193 of file stream.hpp.

template<typename Stream>
template<typename MutableBufferSequence >
std::size_t asio::ssl::stream< Stream >::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.

Parameters
buffersThe buffers into which the data will be read.
Returns
The number of bytes read.
Exceptions
asio::system_errorThrown on failure.
Note
The read_some operation may not read all of the requested number of bytes. Consider using the asio::read function if you need to ensure that the requested amount of data is read before the blocking operation completes.

Definition at line 668 of file stream.hpp.

template<typename Stream>
template<typename MutableBufferSequence >
std::size_t asio::ssl::stream< Stream >::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.

Parameters
buffersThe buffers into which the data will be read.
ecSet to indicate what error occurred, if any.
Returns
The number of bytes read. Returns 0 if an error occurred.
Note
The read_some operation may not read all of the requested number of bytes. Consider using the asio::read function if you need to ensure that the requested amount of data is read before the blocking operation completes.

Definition at line 693 of file stream.hpp.

template<typename Stream>
template<typename VerifyCallback >
void asio::ssl::stream< Stream >::set_verify_callback ( VerifyCallback  callback)
inline

Set the callback used to verify peer certificates.

This function is used to specify a callback function that will be called by the implementation when it needs to verify a peer certificate.

Parameters
callbackThe function object to be used for verifying a certificate. The function signature of the handler must be:
bool preverified, // True if the certificate passed pre-verification.
verify_context& ctx // The peer certificate and other context.
);
The return value of the callback is true if the certificate has passed verification, false otherwise.
Exceptions
asio::system_errorThrown on failure.
Note
Calls SSL_set_verify.

Definition at line 317 of file stream.hpp.

template<typename Stream>
template<typename VerifyCallback >
asio::error_code asio::ssl::stream< Stream >::set_verify_callback ( VerifyCallback  callback,
asio::error_code ec 
)
inline

Set the callback used to verify peer certificates.

This function is used to specify a callback function that will be called by the implementation when it needs to verify a peer certificate.

Parameters
callbackThe function object to be used for verifying a certificate. The function signature of the handler must be:
bool preverified, // True if the certificate passed pre-verification.
verify_context& ctx // The peer certificate and other context.
);
The return value of the callback is true if the certificate has passed verification, false otherwise.
ecSet to indicate what error occurred, if any.
Note
Calls SSL_set_verify.

Definition at line 343 of file stream.hpp.

template<typename Stream>
void asio::ssl::stream< Stream >::set_verify_depth ( int  depth)
inline

Set the peer verification depth.

This function may be used to configure the maximum verification depth allowed by the stream.

Parameters
depthMaximum depth for the certificate chain verification that shall be allowed.
Exceptions
asio::system_errorThrown on failure.
Note
Calls SSL_set_verify_depth.

Definition at line 273 of file stream.hpp.

template<typename Stream>
asio::error_code asio::ssl::stream< Stream >::set_verify_depth ( int  depth,
asio::error_code ec 
)
inline

Set the peer verification depth.

This function may be used to configure the maximum verification depth allowed by the stream.

Parameters
depthMaximum depth for the certificate chain verification that shall be allowed.
ecSet to indicate what error occurred, if any.
Note
Calls SSL_set_verify_depth.

Definition at line 292 of file stream.hpp.

template<typename Stream>
void asio::ssl::stream< Stream >::set_verify_mode ( verify_mode  v)
inline

Set the peer verification mode.

This function may be used to configure the peer verification mode used by the stream. The new mode will override the mode inherited from the context.

Parameters
vA bitmask of peer verification modes. See verify_mode for available values.
Exceptions
asio::system_errorThrown on failure.
Note
Calls SSL_set_verify.

Definition at line 236 of file stream.hpp.

template<typename Stream>
asio::error_code asio::ssl::stream< Stream >::set_verify_mode ( verify_mode  v,
asio::error_code ec 
)
inline

Set the peer verification mode.

This function may be used to configure the peer verification mode used by the stream. The new mode will override the mode inherited from the context.

Parameters
vA bitmask of peer verification modes. See verify_mode for available values.
ecSet to indicate what error occurred, if any.
Note
Calls SSL_set_verify.

Definition at line 255 of file stream.hpp.

template<typename Stream>
void asio::ssl::stream< Stream >::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.

Exceptions
asio::system_errorThrown on failure.

Definition at line 510 of file stream.hpp.

template<typename Stream>
asio::error_code asio::ssl::stream< Stream >::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.

Parameters
ecSet to indicate what error occurred, if any.

Definition at line 524 of file stream.hpp.

template<typename Stream>
template<typename ConstBufferSequence >
std::size_t asio::ssl::stream< Stream >::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.

Parameters
buffersThe data to be written.
Returns
The number of bytes written.
Exceptions
asio::system_errorThrown on failure.
Note
The write_some operation may not transmit all of the data to the peer. Consider using the asio::write function if you need to ensure that all data is written before the blocking operation completes.

Definition at line 577 of file stream.hpp.

template<typename Stream>
template<typename ConstBufferSequence >
std::size_t asio::ssl::stream< Stream >::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.

Parameters
buffersThe data to be written to the stream.
ecSet to indicate what error occurred, if any.
Returns
The number of bytes written. Returns 0 if an error occurred.
Note
The write_some operation may not transmit all of the data to the peer. Consider using the asio::write function if you need to ensure that all data is written before the blocking operation completes.

Definition at line 602 of file stream.hpp.

Member Data Documentation

template<typename Stream>
const ConstBufferSequence& asio::ssl::stream< Stream >::buffers

Definition at line 484 of file stream.hpp.


The documentation for this class was generated from the following file: