boost::system::error_code set_verify_mode( verify_mode v, boost::system::error_code & ec);
This function may be used to configure the peer verification mode used by the context.
A bitmask of peer verification modes. See ssl::verify_mode
for available
values.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_verify
.
Always create a new key when using tmp_dh parameters.
static const long single_dh_use = implementation_defined;
Use a certificate from a memory buffer.
void use_certificate( const const_buffer & certificate, file_format format); » more... boost::system::error_code use_certificate( const const_buffer & certificate, file_format format, boost::system::error_code & ec); » more...
Use a certificate from a memory buffer.
void use_certificate( const const_buffer & certificate, file_format format);
This function is used to load a certificate into the context from a buffer.
The buffer containing the certificate.
The certificate format (ASN.1 or PEM).
Thrown on failure.
Calls SSL_CTX_use_certificate
or SSL_CTX_use_certificate_ASN1.
Use a certificate from a memory buffer.
boost::system::error_code use_certificate( const const_buffer & certificate, file_format format, boost::system::error_code & ec);
This function is used to load a certificate into the context from a buffer.
The buffer containing the certificate.
The certificate format (ASN.1 or PEM).
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_certificate
or SSL_CTX_use_certificate_ASN1.
Use a certificate chain from a memory buffer.
void use_certificate_chain( const const_buffer & chain); » more... boost::system::error_code use_certificate_chain( const const_buffer & chain, boost::system::error_code & ec); » more...
Use a certificate chain from a memory buffer.
void use_certificate_chain( const const_buffer & chain);
This function is used to load a certificate chain into the context from a buffer.
The buffer containing the certificate chain. The certificate chain must use the PEM format.
Thrown on failure.
Calls SSL_CTX_use_certificate
and SSL_CTX_add_extra_chain_cert.
Use a certificate chain from a memory buffer.
boost::system::error_code use_certificate_chain( const const_buffer & chain, boost::system::error_code & ec);
This function is used to load a certificate chain into the context from a buffer.
The buffer containing the certificate chain. The certificate chain must use the PEM format.
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_certificate
and SSL_CTX_add_extra_chain_cert.
Use a certificate chain from a file.
void use_certificate_chain_file( const std::string & filename); » more... boost::system::error_code use_certificate_chain_file( const std::string & filename, boost::system::error_code & ec); » more...
Use a certificate chain from a file.
void use_certificate_chain_file( const std::string & filename);
This function is used to load a certificate chain into the context from a file.
The name of the file containing the certificate. The file must use the PEM format.
Thrown on failure.
Calls SSL_CTX_use_certificate_chain_file
.
Use a certificate chain from a file.
boost::system::error_code use_certificate_chain_file( const std::string & filename, boost::system::error_code & ec);
This function is used to load a certificate chain into the context from a file.
The name of the file containing the certificate. The file must use the PEM format.
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_certificate_chain_file
.
Use a certificate from a file.
void use_certificate_file( const std::string & filename, file_format format); » more... boost::system::error_code use_certificate_file( const std::string & filename, file_format format, boost::system::error_code & ec); » more...
Use a certificate from a file.
void use_certificate_file( const std::string & filename, file_format format);
This function is used to load a certificate into the context from a file.
The name of the file containing the certificate.
The file format (ASN.1 or PEM).
Thrown on failure.
Calls SSL_CTX_use_certificate_file
.
Use a certificate from a file.
boost::system::error_code use_certificate_file( const std::string & filename, file_format format, boost::system::error_code & ec);
This function is used to load a certificate into the context from a file.
The name of the file containing the certificate.
The file format (ASN.1 or PEM).
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_certificate_file
.
Use a private key from a memory buffer.
void use_private_key( const const_buffer & private_key, file_format format); » more... boost::system::error_code use_private_key( const const_buffer & private_key, file_format format, boost::system::error_code & ec); » more...
Use a private key from a memory buffer.
void use_private_key( const const_buffer & private_key, file_format format);
This function is used to load a private key into the context from a buffer.
The buffer containing the private key.
The private key format (ASN.1 or PEM).
Thrown on failure.
Calls SSL_CTX_use_PrivateKey
or SSL_CTX_use_PrivateKey_ASN1.
Use a private key from a memory buffer.
boost::system::error_code use_private_key( const const_buffer & private_key, file_format format, boost::system::error_code & ec);
This function is used to load a private key into the context from a buffer.
The buffer containing the private key.
The private key format (ASN.1 or PEM).
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_PrivateKey
or SSL_CTX_use_PrivateKey_ASN1.
Use a private key from a file.
void use_private_key_file( const std::string & filename, file_format format); » more... boost::system::error_code use_private_key_file( const std::string & filename, file_format format, boost::system::error_code & ec); » more...
Use a private key from a file.
void use_private_key_file( const std::string & filename, file_format format);
This function is used to load a private key into the context from a file.
The name of the file containing the private key.
The file format (ASN.1 or PEM).
Thrown on failure.
Calls SSL_CTX_use_PrivateKey_file
.
Use a private key from a file.
boost::system::error_code use_private_key_file( const std::string & filename, file_format format, boost::system::error_code & ec);
This function is used to load a private key into the context from a file.
The name of the file containing the private key.
The file format (ASN.1 or PEM).
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_PrivateKey_file
.
Use an RSA private key from a memory buffer.
void use_rsa_private_key( const const_buffer & private_key, file_format format); » more... boost::system::error_code use_rsa_private_key( const const_buffer & private_key, file_format format, boost::system::error_code & ec); » more...
Use an RSA private key from a memory buffer.
void use_rsa_private_key( const const_buffer & private_key, file_format format);
This function is used to load an RSA private key into the context from a buffer.
The buffer containing the RSA private key.
The private key format (ASN.1 or PEM).
Thrown on failure.
Calls SSL_CTX_use_RSAPrivateKey
or SSL_CTX_use_RSAPrivateKey_ASN1.
Use an RSA private key from a memory buffer.
boost::system::error_code use_rsa_private_key( const const_buffer & private_key, file_format format, boost::system::error_code & ec);
This function is used to load an RSA private key into the context from a buffer.
The buffer containing the RSA private key.
The private key format (ASN.1 or PEM).
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_RSAPrivateKey
or SSL_CTX_use_RSAPrivateKey_ASN1.
Use an RSA private key from a file.
void use_rsa_private_key_file( const std::string & filename, file_format format); » more... boost::system::error_code use_rsa_private_key_file( const std::string & filename, file_format format, boost::system::error_code & ec); » more...
Use an RSA private key from a file.
void use_rsa_private_key_file( const std::string & filename, file_format format);
This function is used to load an RSA private key into the context from a file.
The name of the file containing the RSA private key.
The file format (ASN.1 or PEM).
Thrown on failure.
Calls SSL_CTX_use_RSAPrivateKey_file
.
Use an RSA private key from a file.
boost::system::error_code use_rsa_private_key_file( const std::string & filename, file_format format, boost::system::error_code & ec);
This function is used to load an RSA private key into the context from a file.
The name of the file containing the RSA private key.
The file format (ASN.1 or PEM).
Set to indicate what error occurred, if any.
Calls SSL_CTX_use_RSAPrivateKey_file
.
Use the specified memory buffer to obtain the temporary Diffie-Hellman parameters.
void use_tmp_dh( const const_buffer & dh); » more... boost::system::error_code use_tmp_dh( const const_buffer & dh, boost::system::error_code & ec); » more...
Use the specified memory buffer to obtain the temporary Diffie-Hellman parameters.
void use_tmp_dh( const const_buffer & dh);
This function is used to load Diffie-Hellman parameters into the context from a buffer.
The memory buffer containing the Diffie-Hellman parameters. The buffer must use the PEM format.
Thrown on failure.
Calls SSL_CTX_set_tmp_dh
.
Use the specified memory buffer to obtain the temporary Diffie-Hellman parameters.
boost::system::error_code use_tmp_dh( const const_buffer & dh, boost::system::error_code & ec);
This function is used to load Diffie-Hellman parameters into the context from a buffer.
The memory buffer containing the Diffie-Hellman parameters. The buffer must use the PEM format.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_tmp_dh
.
Use the specified file to obtain the temporary Diffie-Hellman parameters.
void use_tmp_dh_file( const std::string & filename); » more... boost::system::error_code use_tmp_dh_file( const std::string & filename, boost::system::error_code & ec); » more...
Use the specified file to obtain the temporary Diffie-Hellman parameters.
void use_tmp_dh_file( const std::string & filename);
This function is used to load Diffie-Hellman parameters into the context from a file.
The name of the file containing the Diffie-Hellman parameters. The file must use the PEM format.
Thrown on failure.
Calls SSL_CTX_set_tmp_dh
.
Use the specified file to obtain the temporary Diffie-Hellman parameters.
boost::system::error_code use_tmp_dh_file( const std::string & filename, boost::system::error_code & ec);
This function is used to load Diffie-Hellman parameters into the context from a file.
The name of the file containing the Diffie-Hellman parameters. The file must use the PEM format.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_tmp_dh
.
The ssl::context_base
class is used as a base for the basic_context class template so that we have
a common place to define various enums.
class context_base
|
Name |
Description |
|---|---|
|
File format types. |
|
|
Different methods supported by a context. |
|
|
Bitmask type for SSL options. |
|
|
Purpose of PEM password. |
|
Name |
Description |
|---|---|
|
Protected destructor to prevent deletion through this type. |
|
Name |
Description |
|---|---|
|
Implement various bug workarounds. |
|
|
Disable compression. Compression is disabled by default. |
|
|
Disable SSL v2. |
|
|
Disable SSL v3. |
|
|
Disable TLS v1. |
|
|
Disable TLS v1.1. |
|
|
Disable TLS v1.2. |
|
|
Always create a new key when using tmp_dh parameters. |
Header: boost/asio/ssl/context_base.hpp
Convenience header: boost/asio/ssl.hpp
Different methods supported by a context.
enum method
Generic SSL version 2.
SSL version 2 client.
SSL version 2 server.
Generic SSL version 3.
SSL version 3 client.
SSL version 3 server.
Generic TLS version 1.
TLS version 1 client.
TLS version 1 server.
Generic SSL/TLS.
SSL/TLS client.
SSL/TLS server.
Generic TLS version 1.1.
TLS version 1.1 client.
TLS version 1.1 server.
Generic TLS version 1.2.
TLS version 1.2 client.
TLS version 1.2 server.
Disable compression. Compression is disabled by default.
static const long no_compression = implementation_defined;
static const long no_tlsv1_1 = implementation_defined;
static const long no_tlsv1_2 = implementation_defined;
typedef long options;
Header: boost/asio/ssl/context_base.hpp
Convenience header: boost/asio/ssl.hpp
enum password_purpose
The password is needed for reading/decryption.
The password is needed for writing/encryption.
Always create a new key when using tmp_dh parameters.
static const long single_dh_use = implementation_defined;
const boost::system::error_category & get_stream_category();
Header: boost/asio/ssl/error.hpp
Convenience header: boost/asio/ssl.hpp
boost::system::error_code make_error_code( stream_errors e);
Header: boost/asio/ssl/error.hpp
Convenience header: boost/asio/ssl.hpp
static const boost::system::error_category & stream_category = boost::asio::ssl::error::get_stream_category();
Header: boost/asio/ssl/error.hpp
Convenience header: boost/asio/ssl.hpp
enum stream_errors
The underlying stream closed before the ssl stream gracefully shut down.
Header: boost/asio/ssl/error.hpp
Convenience header: boost/asio/ssl.hpp
Verifies a certificate against a hostname according to the rules described in RFC 2818.
class rfc2818_verification
|
Name |
Description |
|---|---|
|
The type of the function object's result. |
|
Name |
Description |
|---|---|
|
Perform certificate verification. |
|
|
Constructor. |
The following example shows how to synchronously open a secure connection to a given host name:
using boost::asio::ip::tcp; namespace ssl = boost::asio::ssl; typedef ssl::stream<tcp::socket> ssl_socket; // Create a context that uses the default paths for finding CA certificates. ssl::context ctx(ssl::context::sslv23); ctx.set_default_verify_paths(); // Open a socket and connect it to the remote host. boost::asio::io_service io_service; ssl_socket sock(io_service, ctx); tcp::resolver resolver(io_service); tcp::resolver::query query("host.name", "https"); boost::asio::connect(sock.lowest_layer(), resolver.resolve(query)); sock.lowest_layer().set_option(tcp::no_delay(true)); // Perform SSL handshake and verify the remote host's certificate. sock.set_verify_mode(ssl::verify_peer); sock.set_verify_callback(ssl::rfc2818_verification("host.name")); sock.handshake(ssl_socket::client); // ... read and write as normal ...
Header: boost/asio/ssl/rfc2818_verification.hpp
Convenience header: boost/asio/ssl.hpp
The type of the function object's result.
typedef bool result_type;
Header: boost/asio/ssl/rfc2818_verification.hpp
Convenience header: boost/asio/ssl.hpp
rfc2818_verification( const std::string & host);
Provides stream-oriented functionality using SSL.
template< typename Stream> class stream : public ssl::stream_base, noncopyable
|
Name |
Description |
|---|---|
|
Structure for use with deprecated impl_type. |
|
|
Different handshake types. |
|
|
(Deprecated: Use native_handle_type.) The underlying implementation type. |
|
|
The type of the lowest layer. |
|
|
The native handle type of the SSL stream. |
|
|
The type of the next layer. |
|
Name |
Description |
|---|---|
|
Start an asynchronous SSL handshake. |
|
|
Start an asynchronous read. |
|
|
Asynchronously shut down SSL on the stream. |
|
|
Start an asynchronous write. |
|
|
Get the io_service associated with the object. |
|
|
Perform SSL handshaking. |
|
|
(Deprecated: Use native_handle().) Get the underlying implementation in the native type. |
|
|
Get a reference to the lowest layer. |
|
|
Get the underlying implementation in the native type. |
|
|
Get a reference to the next layer. |
|
|
Read some data from the stream. |
|
|
Set the callback used to verify peer certificates. |
|
|
Set the peer verification depth. |
|
|
Set the peer verification mode. |
|
|
Shut down SSL on the stream. |
|
|
Construct a stream. |
|
|
Write some data to the stream. |
|
|
Destructor. |
The stream class template provides asynchronous and blocking stream-oriented functionality using SSL.
Distinct objects: Safe.
Shared objects: Unsafe. The application must also ensure that all asynchronous operations are performed within the same implicit or explicit strand.
To use the SSL stream template with an ip::tcp::socket
, you would write:
boost::asio::io_service io_service; boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23); boost::asio::ssl::stream<asio:ip::tcp::socket> sock(io_service, ctx);
Header: boost/asio/ssl/stream.hpp
Convenience header: boost/asio/ssl.hpp
Start an asynchronous SSL handshake.
template< typename HandshakeHandler> void-or-deduced async_handshake( handshake_type type, HandshakeHandler handler); » more... template< typename ConstBufferSequence, typename BufferedHandshakeHandler> void-or-deduced async_handshake( handshake_type type, const ConstBufferSequence & buffers, BufferedHandshakeHandler handler); » more...
Start an asynchronous SSL handshake.
template< typename HandshakeHandler> void-or-deduced async_handshake( handshake_type type, HandshakeHandler handler);
This function is used to asynchronously perform an SSL handshake on the stream. This function call always returns immediately.
The type of handshaking to be performed, i.e. as a client or as a server.
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 boost::system::error_code& error // Result of operation. );
Start an asynchronous SSL handshake.
template< typename ConstBufferSequence, typename BufferedHandshakeHandler> void-or-deduced async_handshake( handshake_type type, const ConstBufferSequence & buffers, BufferedHandshakeHandler handler);
This function is used to asynchronously perform an SSL handshake on the stream. This function call always returns immediately.
The type of handshaking to be performed, i.e. as a client or as a server.
The 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.
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 boost::system::error_code& error, // Result of operation. std::size_t bytes_transferred // Amount of buffers used in handshake. );
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_read_some( const MutableBufferSequence & buffers, ReadHandler handler);
This function is used to asynchronously read one or more bytes of data from the stream. The function call always returns immediately.
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.
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 boost::system::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes read. );
The async_read_some operation may not read all of the requested number
of bytes. Consider using the async_read
function if you need
to ensure that the requested amount of data is read before the asynchronous
operation completes.
Asynchronously shut down SSL on the stream.
template< typename ShutdownHandler> void-or-deduced async_shutdown( ShutdownHandler handler);
This function is used to asynchronously shut down SSL on the stream. This function call always returns immediately.
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 boost::system::error_code& error // Result of operation. );
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_write_some( const ConstBufferSequence & buffers, WriteHandler handler);
This function is used to asynchronously write one or more bytes of data to the stream. The function call always returns immediately.
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.
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 boost::system::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes written. );
The async_write_some operation may not transmit all of the data to the
peer. Consider using the async_write
function if you need
to ensure that all data is written before the blocking operation completes.
Get the io_service
associated with the
object.
boost::asio::io_service & get_io_service();
This function may be used to obtain the io_service
object that the stream
uses to dispatch handlers for asynchronous operations.
A reference to the io_service
object that stream
will use to dispatch handlers. Ownership is not transferred to the caller.
void handshake( handshake_type type); » more... boost::system::error_code handshake( handshake_type type, boost::system::error_code & ec); » more... template< typename ConstBufferSequence> void handshake( handshake_type type, const ConstBufferSequence & buffers); » more... template< typename ConstBufferSequence> boost::system::error_code handshake( handshake_type type, const ConstBufferSequence & buffers, boost::system::error_code & ec); » more...
Perform SSL handshaking.
void handshake( handshake_type type);
This function is used to perform SSL handshaking on the stream. The function call will block until handshaking is complete or an error occurs.
The type of handshaking to be performed, i.e. as a client or as a server.
Thrown on failure.
Perform SSL handshaking.
boost::system::error_code handshake( handshake_type type, boost::system::error_code & ec);
This function is used to perform SSL handshaking on the stream. The function call will block until handshaking is complete or an error occurs.
The type of handshaking to be performed, i.e. as a client or as a server.
Set to indicate what error occurred, if any.
Perform SSL handshaking.
template< typename ConstBufferSequence> void handshake( handshake_type type, const ConstBufferSequence & buffers);
This function is used to perform SSL handshaking on the stream. The function call will block until handshaking is complete or an error occurs.
The type of handshaking to be performed, i.e. as a client or as a server.
The buffered data to be reused for the handshake.
Thrown on failure.
Perform SSL handshaking.
template< typename ConstBufferSequence> boost::system::error_code handshake( handshake_type type, const ConstBufferSequence & buffers, boost::system::error_code & ec);
This function is used to perform SSL handshaking on the stream. The function call will block until handshaking is complete or an error occurs.
The type of handshaking to be performed, i.e. as a client or as a server.
The buffered data to be reused for the handshake.
Set to indicate what error occurred, if any.
enum handshake_type
Perform handshaking as a client.
Perform handshaking as a server.
(Deprecated: Use native_handle()
.) Get the underlying implementation in
the native type.
impl_type impl();
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.
(Deprecated: Use native_handle_type.) The underlying implementation type.
typedef impl_struct * impl_type;
Header: boost/asio/ssl/stream.hpp
Convenience header: boost/asio/ssl.hpp
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer(); » more... const lowest_layer_type & lowest_layer() const; » more...
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer();
This function returns a reference to the lowest layer in a stack of stream layers.
A reference to the lowest layer in the stack of stream layers. Ownership is not transferred to the caller.
Get a reference to the lowest layer.
const lowest_layer_type & lowest_layer() const;
This function returns a reference to the lowest layer in a stack of stream layers.
A reference to the lowest layer in the stack of stream layers. Ownership is not transferred to the caller.
typedef next_layer_type::lowest_layer_type lowest_layer_type;
Header: boost/asio/ssl/stream.hpp
Convenience header: boost/asio/ssl.hpp
Get the underlying implementation in the native type.
native_handle_type native_handle();
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.
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:
boost::asio::ssl::stream<asio:ip::tcp::socket> sock(io_service, ctx); // ... 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) { // ... } }
The native handle type of the SSL stream.
typedef SSL * native_handle_type;
Header: boost/asio/ssl/stream.hpp
Convenience header: boost/asio/ssl.hpp
Get a reference to the next layer.
const next_layer_type & next_layer() const; » more... next_layer_type & next_layer(); » more...
Get a reference to the next layer.
const next_layer_type & next_layer() const;
This function returns a reference to the next layer in a stack of stream layers.
A reference to the next layer in the stack of stream layers. Ownership is not transferred to the caller.
Get a reference to the next layer.
next_layer_type & next_layer();
This function returns a reference to the next layer in a stack of stream layers.
A reference to the next layer in the stack of stream layers. Ownership is not transferred to the caller.
typedef remove_reference< Stream >::type next_layer_type;
Header: boost/asio/ssl/stream.hpp
Convenience header: boost/asio/ssl.hpp
Read some data from the stream.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers); » more... template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers, boost::system::error_code & ec); » more...
Read some data from the stream.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers);
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.
The buffers into which the data will be read.
The number of bytes read.
Thrown on failure.
The read_some operation may not read all of the requested number of bytes.
Consider using the read
function if you need to
ensure that the requested amount of data is read before the blocking
operation completes.
Read some data from the stream.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers, boost::system::error_code & ec);
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.
The buffers into which the data will be read.
Set to indicate what error occurred, if any.
The number of bytes read. Returns 0 if an error occurred.
The read_some operation may not read all of the requested number of bytes.
Consider using the read
function if you need to
ensure that the requested amount of data is read before the blocking
operation completes.
Set the callback used to verify peer certificates.
template< typename VerifyCallback> void set_verify_callback( VerifyCallback callback); » more... template< typename VerifyCallback> boost::system::error_code set_verify_callback( VerifyCallback callback, boost::system::error_code & ec); » more...
Set the callback used to verify peer certificates.
template< typename VerifyCallback> void set_verify_callback( VerifyCallback callback);
This function is used to specify a callback function that will be called by the implementation when it needs to verify a peer certificate.
The function object to be used for verifying a certificate. The function signature of the handler must be:
bool verify_callback( 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.
Thrown on failure.
Calls SSL_set_verify
.
Set the callback used to verify peer certificates.
template< typename VerifyCallback> boost::system::error_code set_verify_callback( VerifyCallback callback, boost::system::error_code & ec);
This function is used to specify a callback function that will be called by the implementation when it needs to verify a peer certificate.
The function object to be used for verifying a certificate. The function signature of the handler must be:
bool verify_callback( 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.
Set to indicate what error occurred, if any.
Calls SSL_set_verify
.
Set the peer verification depth.
void set_verify_depth( int depth); » more... boost::system::error_code set_verify_depth( int depth, boost::system::error_code & ec); » more...
Set the peer verification depth.
void set_verify_depth( int depth);
This function may be used to configure the maximum verification depth allowed by the stream.
Maximum depth for the certificate chain verification that shall be allowed.
Thrown on failure.
Calls SSL_set_verify_depth
.
Set the peer verification depth.
boost::system::error_code set_verify_depth( int depth, boost::system::error_code & ec);
This function may be used to configure the maximum verification depth allowed by the stream.
Maximum depth for the certificate chain verification that shall be allowed.
Set to indicate what error occurred, if any.
Calls SSL_set_verify_depth
.
Set the peer verification mode.
void set_verify_mode( verify_mode v); » more... boost::system::error_code set_verify_mode( verify_mode v, boost::system::error_code & ec); » more...
Set the peer verification mode.
void set_verify_mode( verify_mode v);
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.
A bitmask of peer verification modes. See ssl::verify_mode
for available
values.
Thrown on failure.
Calls SSL_set_verify
.
Set the peer verification mode.
boost::system::error_code set_verify_mode( verify_mode v, boost::system::error_code & ec);
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.
A bitmask of peer verification modes. See ssl::verify_mode
for available
values.
Set to indicate what error occurred, if any.
Calls SSL_set_verify
.
void shutdown(); » more... boost::system::error_code shutdown( boost::system::error_code & ec); » more...
 The function call will block until SSL has been shut down or an error occurs.
Thrown on failure.
 The function call will block until SSL has been shut down or an error occurs.
Set to indicate what error occurred, if any.
template< typename Arg> stream( Arg & arg, context & ctx);
This constructor creates a stream and initialises the underlying stream object.
The argument to be passed to initialise the underlying stream.
The SSL context to be used for the stream.
Write some data to the stream.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers); » more... template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers, boost::system::error_code & ec); » more...
Write some data to the stream.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers);
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.
The data to be written.
The number of bytes written.
Thrown on failure.
The write_some operation may not transmit all of the data to the peer.
Consider using the write
function if you need to
ensure that all data is written before the blocking operation completes.
Write some data to the stream.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers, boost::system::error_code & ec);
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.
The data to be written to the stream.
Set to indicate what error occurred, if any.
The number of bytes written. Returns 0 if an error occurred.
The write_some operation may not transmit all of the data to the peer.
Consider using the write
function if you need to
ensure that all data is written before the blocking operation completes.
Structure for use with deprecated impl_type.
struct impl_struct
|
Name |
Description |
|---|---|
Header: boost/asio/ssl/stream.hpp
Convenience header: boost/asio/ssl.hpp
The ssl::stream_base
class is used as a base for the ssl::stream
class template so that we have a common place to define various enums.
class stream_base
|
Name |
Description |
|---|---|
|
Different handshake types. |
|
Name |
Description |
|---|---|
|
Protected destructor to prevent deletion through this type. |
Header: boost/asio/ssl/stream_base.hpp
Convenience header: boost/asio/ssl.hpp
enum handshake_type
Perform handshaking as a client.
Perform handshaking as a server.
Do not request client certificate on renegotiation.
Ignored unless ssl::verify_peer
is set.
const int verify_client_once = implementation_defined;
Header: boost/asio/ssl/verify_mode.hpp
Convenience header: boost/asio/ssl.hpp
A simple wrapper around the X509_STORE_CTX type, used during verification of a peer certificate.
class verify_context : noncopyable
|
Name |
Description |
|---|---|
|
The native handle type of the verification context. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation in the native type. |
|
|
Constructor. |
The ssl::verify_context
does not own the underlying X509_STORE_CTX object.
Header: boost/asio/ssl/verify_context.hpp
Convenience header: boost/asio/ssl.hpp
Get the underlying implementation in the native type.
native_handle_type native_handle();
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.
The native handle type of the verification context.
typedef X509_STORE_CTX * native_handle_type;
Header: boost/asio/ssl/verify_context.hpp
Convenience header: boost/asio/ssl.hpp
Fail verification if the peer has no certificate.
Ignored unless ssl::verify_peer
is set.
const int verify_fail_if_no_peer_cert = implementation_defined;
Header: boost/asio/ssl/verify_mode.hpp
Convenience header: boost/asio/ssl.hpp
Bitmask type for peer verification.
typedef int verify_mode;
Possible values are:
Header: boost/asio/ssl/verify_mode.hpp
Convenience header: boost/asio/ssl.hpp
const int verify_none = implementation_defined;
Header: boost/asio/ssl/verify_mode.hpp
Convenience header: boost/asio/ssl.hpp
const int verify_peer = implementation_defined;
Header: boost/asio/ssl/verify_mode.hpp
Convenience header: boost/asio/ssl.hpp
Typedef for a timer based on the steady clock.
typedef basic_waitable_timer< chrono::steady_clock > steady_timer;
|
Name |
Description |
|---|---|
|
The clock type. |
|
|
The duration type of the clock. |
|
|
The underlying implementation type of I/O object. |
|
|
The type of the service that will be used to provide I/O operations. |
|
|
The time point type of the clock. |
|
|
The wait traits type. |
|
Name |
Description |
|---|---|
|
Start an asynchronous wait on the timer. |
|
|
Constructor. Constructor to set a particular expiry time as an absolute time. Constructor to set a particular expiry time relative to now. |
|
|
Cancel any asynchronous operations that are waiting on the timer. |
|
|
Cancels one asynchronous operation that is waiting on the timer. |
|
|
Get the timer's expiry time as an absolute time. Set the timer's expiry time as an absolute time. |
|
|
Get the timer's expiry time relative to now. Set the timer's expiry time relative to now. |
|
|
Get the io_service associated with the object. |
|
|
Perform a blocking wait on the timer. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The basic_waitable_timer
class template
provides the ability to perform a blocking or asynchronous wait for a timer
to expire.
A waitable timer is always in one of two states: "expired" or "not
expired". If the wait()
or async_wait()
function is called on an expired timer,
the wait operation will complete immediately.
Most applications will use one of the steady_timer
, system_timer
or high_resolution_timer
typedefs.
This waitable timer functionality is for use with the C++11 standard library's
<chrono>
facility, or with the Boost.Chrono library.
Distinct objects: Safe.
Shared objects: Unsafe.
Performing a blocking wait (C++11):
// Construct a timer without setting an expiry time. boost::asio::steady_timer timer(io_service); // Set an expiry time relative to now. timer.expires_from_now(std::chrono::seconds(5)); // Wait for the timer to expire. timer.wait();
Performing an asynchronous wait (C++11):
void handler(const boost::system::error_code& error) { if (!error) { // Timer expired. } } ... // Construct a timer with an absolute expiry time. boost::asio::steady_timer timer(io_service, std::chrono::steady_clock::now() + std::chrono::seconds(60)); // Start an asynchronous wait. timer.async_wait(handler);
Changing the expiry time of a timer while there are pending asynchronous waits causes those wait operations to be cancelled. To ensure that the action associated with the timer is performed only once, use something like this: used:
void on_some_event() { if (my_timer.expires_from_now(seconds(5)) > 0) { // We managed to cancel the timer. Start new asynchronous wait. my_timer.async_wait(on_timeout); } else { // Too late, timer has already expired! } } void on_timeout(const boost::system::error_code& e) { if (e != boost::asio::error::operation_aborted) { // Timer was not cancelled, take necessary action. } }
boost::asio::basic_waitable_timer::expires_from_now()
function cancels any pending asynchronous waits, and returns the number
of asynchronous waits that were cancelled. If it returns 0 then you were
too late and the wait handler has already been executed, or will soon
be executed. If it returns 1 then the wait handler was successfully cancelled.
boost::asio::error::operation_aborted
.
This typedef uses the C++11 <chrono>
standard library facility, if available. Otherwise, it may use the Boost.Chrono
library. To explicitly utilise Boost.Chrono, use the basic_waitable_timer
template directly:
typedef basic_waitable_timer<boost::chrono::steady_clock> timer;
Header: boost/asio/steady_timer.hpp
Convenience header: None
(Deprecated: Use io_service::strand
.) Typedef for backwards compatibility.
typedef boost::asio::io_service::strand strand;
|
Name |
Description |
|---|---|
|
Request the strand to invoke the given handler. |
|
|
Get the io_service associated with the strand. |
|
|
Request the strand to invoke the given handler and return immediately. |
|
|
Determine whether the strand is running in the current thread. |
|
|
Constructor. |
|
|
Create a new handler that automatically dispatches the wrapped handler on the strand. |
|
|
Destructor. |
The io_service::strand
class provides the ability
to post and dispatch handlers with the guarantee that none of those handlers
will execute concurrently.
Given:
s
a
meeting completion
handler requirements
a1
which is
an arbitrary copy of a
made by the implementation
b
meeting completion
handler requirements
b1
which is
an arbitrary copy of b
made by the implementation
if any of the following conditions are true:
s.post(a)
happens-before s.post(b)
s.post(a)
happens-before s.dispatch(b)
,
where the latter is performed outside the strand
s.dispatch(a)
happens-before s.post(b)
,
where the former is performed outside the strand
s.dispatch(a)
happens-before s.dispatch(b)
,
where both are performed outside the strand
then asio_handler_invoke(a1,
&a1)
happens-before asio_handler_invoke(b1,
&b1)
.
Note that in the following case:
async_op_1(..., s.wrap(a)); async_op_2(..., s.wrap(b));
the completion of the first async operation will perform s.dispatch(a)
,
and the second will perform s.dispatch(b)
,
but the order in which those are performed is unspecified. That is, you cannot
state whether one happens-before the other. Therefore none of the above conditions
are met and no ordering guarantee is made.
The implementation makes no guarantee that handlers posted or dispatched
through different strand
objects will be invoked concurrently.
Distinct objects: Safe.
Shared objects: Safe.
Header: boost/asio/strand.hpp
Convenience header: boost/asio.hpp
Default service implementation for a stream socket.
template< typename Protocol> class stream_socket_service : public io_service::service
|
Name |
Description |
|---|---|
|
The endpoint type. |
|
|
The type of a stream socket implementation. |
|
|
The native socket type. |
|
|
(Deprecated: Use native_handle_type.) The native socket type. |
|
|
The protocol type. |
|
Name |
Description |
|---|---|
|
Assign an existing native socket to a stream socket. |
|
|
Start an asynchronous connect. |
|
|
Start an asynchronous receive. |
|
|
Start an asynchronous send. |
|
|
Determine whether the socket is at the out-of-band data mark. |
|
|
Determine the number of bytes available for reading. |
|
|
Bind the stream socket to the specified local endpoint. |
|
|
Cancel all asynchronous operations associated with the socket. |
|
|
Close a stream socket implementation. |
|
|
Connect the stream socket to the specified endpoint. |
|
|
Construct a new stream socket implementation. |
|
|
Move-construct a new stream socket implementation from another protocol type. |
|
|
Destroy a stream socket implementation. |
|
|
Get the io_service object that owns the service. |
|
|
Get a socket option. |
|
|
Perform an IO control command on the socket. |
|
|
Determine whether the socket is open. |
|
|
Get the local endpoint. |
|
|
Move-assign from another stream socket implementation. |
|
|
Move-construct a new stream socket implementation. |
|
|
(Deprecated: Use native_handle().) Get the native socket implementation. |
|
|
Get the native socket implementation. |
|
|
Gets the non-blocking mode of the native socket implementation. Sets the non-blocking mode of the native socket implementation. |
|
|
Gets the non-blocking mode of the socket. Sets the non-blocking mode of the socket. |
|
|
Open a stream socket. |
|
|
Receive some data from the peer. |
|
|
Get the remote endpoint. |
|
|
Send the given data to the peer. |
|
|
Set a socket option. |
|
|
Disable sends or receives on the socket. |
|
|
Construct a new stream socket service for the specified io_service. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/stream_socket_service.hpp
Convenience header: boost/asio.hpp
Assign an existing native socket to a stream socket.
boost::system::error_code assign( implementation_type & impl, const protocol_type & protocol, const native_handle_type & native_socket, boost::system::error_code & ec);
Start an asynchronous connect.
template< typename ConnectHandler> void-or-deduced async_connect( implementation_type & impl, const endpoint_type & peer_endpoint, ConnectHandler handler);
Start an asynchronous receive.
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_receive( implementation_type & impl, const MutableBufferSequence & buffers, socket_base::message_flags flags, ReadHandler handler);
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_send( implementation_type & impl, const ConstBufferSequence & buffers, socket_base::message_flags flags, WriteHandler handler);
Determine whether the socket is at the out-of-band data mark.
bool at_mark( const implementation_type & impl, boost::system::error_code & ec) const;
Determine the number of bytes available for reading.
std::size_t available( const implementation_type & impl, boost::system::error_code & ec) const;
Bind the stream socket to the specified local endpoint.
boost::system::error_code bind( implementation_type & impl, const endpoint_type & endpoint, boost::system::error_code & ec);
Cancel all asynchronous operations associated with the socket.
boost::system::error_code cancel( implementation_type & impl, boost::system::error_code & ec);
Close a stream socket implementation.
boost::system::error_code close( implementation_type & impl, boost::system::error_code & ec);
Connect the stream socket to the specified endpoint.
boost::system::error_code connect( implementation_type & impl, const endpoint_type & peer_endpoint, boost::system::error_code & ec);
Move-construct a new stream socket implementation from another protocol type.
template< typename Protocol1> void converting_move_construct( implementation_type & impl, typename stream_socket_service< Protocol1 >::implementation_type & other_impl, typename enable_if< is_convertible< Protocol1, Protocol >::value >::type * = 0);
typedef Protocol::endpoint endpoint_type;
Header: boost/asio/stream_socket_service.hpp
Convenience header: boost/asio.hpp
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
template< typename GettableSocketOption> boost::system::error_code get_option( const implementation_type & impl, GettableSocketOption & option, boost::system::error_code & ec) const;
The type of a stream socket implementation.
typedef implementation_defined implementation_type;
Header: boost/asio/stream_socket_service.hpp
Convenience header: boost/asio.hpp
Perform an IO control command on the socket.
template< typename IoControlCommand> boost::system::error_code io_control( implementation_type & impl, IoControlCommand & command, boost::system::error_code & ec);
endpoint_type local_endpoint( const implementation_type & impl, boost::system::error_code & ec) const;
Move-assign from another stream socket implementation.
void move_assign( implementation_type & impl, stream_socket_service & other_service, implementation_type & other_impl);
Move-construct a new stream socket implementation.
void move_construct( implementation_type & impl, implementation_type & other_impl);
(Deprecated: Use native_handle()
.) Get the native socket implementation.
native_type native( implementation_type & impl);
Get the native socket implementation.
native_handle_type native_handle( implementation_type & impl);
typedef implementation_defined native_handle_type;
Header: boost/asio/stream_socket_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the native socket implementation.
bool native_non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the native socket implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the native socket implementation.
bool native_non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the native socket implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
(Deprecated: Use native_handle_type.) The native socket type.
typedef implementation_defined native_type;
Header: boost/asio/stream_socket_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the socket.
bool non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the socket.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the socket.
bool non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the socket.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
boost::system::error_code open( implementation_type & impl, const protocol_type & protocol, boost::system::error_code & ec);
typedef Protocol protocol_type;
Header: boost/asio/stream_socket_service.hpp
Convenience header: boost/asio.hpp
Receive some data from the peer.
template< typename MutableBufferSequence> std::size_t receive( implementation_type & impl, const MutableBufferSequence & buffers, socket_base::message_flags flags, boost::system::error_code & ec);
endpoint_type remote_endpoint( const implementation_type & impl, boost::system::error_code & ec) const;
Send the given data to the peer.
template< typename ConstBufferSequence> std::size_t send( implementation_type & impl, const ConstBufferSequence & buffers, socket_base::message_flags flags, boost::system::error_code & ec);
template< typename SettableSocketOption> boost::system::error_code set_option( implementation_type & impl, const SettableSocketOption & option, boost::system::error_code & ec);
Disable sends or receives on the socket.
boost::system::error_code shutdown( implementation_type & impl, socket_base::shutdown_type what, boost::system::error_code & ec);
Construct a new stream socket
service for the specified io_service
.
stream_socket_service( boost::asio::io_service & io_service);
Typedef for the typical usage of basic_streambuf
.
typedef basic_streambuf streambuf;
|
Name |
Description |
|---|---|
|
The type used to represent the input sequence as a list of buffers. |
|
|
The type used to represent the output sequence as a list of buffers. |
|
Name |
Description |
|---|---|
|
Construct a basic_streambuf object. |
|
|
Move characters from the output sequence to the input sequence. |
|
|
Remove characters from the input sequence. |
|
|
Get a list of buffers that represents the input sequence. |
|
|
Get the maximum size of the basic_streambuf. |
|
|
Get a list of buffers that represents the output sequence, with the given size. |
|
|
Get the size of the input sequence. |
|
Name |
Description |
|---|---|
|
Override std::streambuf behaviour. |
|
|
Override std::streambuf behaviour. |
The basic_streambuf
class
is derived from std::streambuf
to associate the streambuf's
input and output sequences with one or more character arrays. These character
arrays are internal to the basic_streambuf
object, but direct access to the array elements is provided to permit them
to be used efficiently with I/O operations. Characters written to the output
sequence of a basic_streambuf
object are appended to the input sequence of the same object.
The basic_streambuf
class's
public interface is intended to permit the following implementation strategies:
The constructor for basic_streambuf
accepts a size_t
argument specifying the maximum
of the sum of the sizes of the input sequence and output sequence. During
the lifetime of the basic_streambuf
object, the following invariant holds:
size() <= max_size()
Any member function that would, if successful, cause the invariant to be
violated shall throw an exception of class std::length_error
.
The constructor for basic_streambuf
takes an Allocator argument. A copy of this argument is used for any memory
allocation performed, by the constructor and by all member functions, during
the lifetime of each basic_streambuf
object.
Writing directly from an streambuf to a socket:
boost::asio::streambuf b; std::ostream os(&b); os << "Hello, World!\n"; // try sending some data in input sequence size_t n = sock.send(b.data()); b.consume(n); // sent data is removed from input sequence
Reading from a socket directly into a streambuf:
boost::asio::streambuf b; // reserve 512 bytes in output sequence boost::asio::streambuf::mutable_buffers_type bufs = b.prepare(512); size_t n = sock.receive(bufs); // received data is "committed" from output sequence to input sequence b.commit(n); std::istream is(&b); std::string s; is >> s;
Header: boost/asio/streambuf.hpp
Convenience header: boost/asio.hpp
Typedef for a timer based on the system clock.
typedef basic_waitable_timer< chrono::system_clock > system_timer;
|
Name |
Description |
|---|---|
|
The clock type. |
|
|
The duration type of the clock. |
|
|
The underlying implementation type of I/O object. |
|
|
The type of the service that will be used to provide I/O operations. |
|
|
The time point type of the clock. |
|
|
The wait traits type. |
|
Name |
Description |
|---|---|
|
Start an asynchronous wait on the timer. |
|
|
Constructor. Constructor to set a particular expiry time as an absolute time. Constructor to set a particular expiry time relative to now. |
|
|
Cancel any asynchronous operations that are waiting on the timer. |
|
|
Cancels one asynchronous operation that is waiting on the timer. |
|
|
Get the timer's expiry time as an absolute time. Set the timer's expiry time as an absolute time. |
|
|
Get the timer's expiry time relative to now. Set the timer's expiry time relative to now. |
|
|
Get the io_service associated with the object. |
|
|
Perform a blocking wait on the timer. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The basic_waitable_timer
class template
provides the ability to perform a blocking or asynchronous wait for a timer
to expire.
A waitable timer is always in one of two states: "expired" or "not
expired". If the wait()
or async_wait()
function is called on an expired timer,
the wait operation will complete immediately.
Most applications will use one of the steady_timer
, system_timer
or high_resolution_timer
typedefs.
This waitable timer functionality is for use with the C++11 standard library's
<chrono>
facility, or with the Boost.Chrono library.
Distinct objects: Safe.
Shared objects: Unsafe.
Performing a blocking wait (C++11):
// Construct a timer without setting an expiry time. boost::asio::steady_timer timer(io_service); // Set an expiry time relative to now. timer.expires_from_now(std::chrono::seconds(5)); // Wait for the timer to expire. timer.wait();
Performing an asynchronous wait (C++11):
void handler(const boost::system::error_code& error) { if (!error) { // Timer expired. } } ... // Construct a timer with an absolute expiry time. boost::asio::steady_timer timer(io_service, std::chrono::steady_clock::now() + std::chrono::seconds(60)); // Start an asynchronous wait. timer.async_wait(handler);
Changing the expiry time of a timer while there are pending asynchronous waits causes those wait operations to be cancelled. To ensure that the action associated with the timer is performed only once, use something like this: used:
void on_some_event() { if (my_timer.expires_from_now(seconds(5)) > 0) { // We managed to cancel the timer. Start new asynchronous wait. my_timer.async_wait(on_timeout); } else { // Too late, timer has already expired! } } void on_timeout(const boost::system::error_code& e) { if (e != boost::asio::error::operation_aborted) { // Timer was not cancelled, take necessary action. } }
boost::asio::basic_waitable_timer::expires_from_now()
function cancels any pending asynchronous waits, and returns the number
of asynchronous waits that were cancelled. If it returns 0 then you were
too late and the wait handler has already been executed, or will soon
be executed. If it returns 1 then the wait handler was successfully cancelled.
boost::asio::error::operation_aborted
.
This typedef uses the C++11 <chrono>
standard library facility, if available. Otherwise, it may use the Boost.Chrono
library. To explicitly utilise Boost.Chrono, use the basic_waitable_timer
template directly:
typedef basic_waitable_timer<boost::chrono::system_clock> timer;
Header: boost/asio/system_timer.hpp
Convenience header: None
Time traits specialised for posix_time.
template<> struct time_traits< boost::posix_time::ptime >
|
Name |
Description |
|---|---|
|
The duration type. |
|
|
The time type. |
|
Name |
Description |
|---|---|
|
Add a duration to a time. |
|
|
Test whether one time is less than another. |
|
|
Get the current time. |
|
|
Subtract one time from another. |
|
|
Convert to POSIX duration type. |
Header: boost/asio/time_traits.hpp
Convenience header: boost/asio.hpp
static time_type add( const time_type & t, const duration_type & d);
typedef boost::posix_time::time_duration duration_type;
Header: boost/asio/time_traits.hpp
Convenience header: boost/asio.hpp
Test whether one time is less than another.
static bool less_than( const time_type & t1, const time_type & t2);
Subtract one time from another.
static duration_type subtract( const time_type & t1, const time_type & t2);
typedef boost::posix_time::ptime time_type;
Header: boost/asio/time_traits.hpp
Convenience header: boost/asio.hpp
Return a completion condition function object that indicates that a read or write operation should continue until all of the data has been transferred, or until an error occurs.
unspecified transfer_all();
This function is used to create an object, of unspecified type, that meets CompletionCondition requirements.
Reading until a buffer is full:
boost::array<char, 128> buf; boost::system::error_code ec; std::size_t n = boost::asio::read( sock, boost::asio::buffer(buf), boost::asio::transfer_all(), ec); if (ec) { // An error occurred. } else { // n == 128 }
Header: boost/asio/completion_condition.hpp
Convenience header: boost/asio.hpp
Return a completion condition function object that indicates that a read or write operation should continue until a minimum number of bytes has been transferred, or until an error occurs.
unspecified transfer_at_least( std::size_t minimum);
This function is used to create an object, of unspecified type, that meets CompletionCondition requirements.
Reading until a buffer is full or contains at least 64 bytes:
boost::array<char, 128> buf; boost::system::error_code ec; std::size_t n = boost::asio::read( sock, boost::asio::buffer(buf), boost::asio::transfer_at_least(64), ec); if (ec) { // An error occurred. } else { // n >= 64 && n <= 128 }
Header: boost/asio/completion_condition.hpp
Convenience header: boost/asio.hpp
Return a completion condition function object that indicates that a read or write operation should continue until an exact number of bytes has been transferred, or until an error occurs.
unspecified transfer_exactly( std::size_t size);
This function is used to create an object, of unspecified type, that meets CompletionCondition requirements.
Reading until a buffer is full or contains exactly 64 bytes:
boost::array<char, 128> buf; boost::system::error_code ec; std::size_t n = boost::asio::read( sock, boost::asio::buffer(buf), boost::asio::transfer_exactly(64), ec); if (ec) { // An error occurred. } else { // n == 64 }
Header: boost/asio/completion_condition.hpp
Convenience header: boost/asio.hpp
A special value, similar to std::nothrow.
constexpr use_future_t use_future;
See the documentation for use_future_t
for a usage example.
Header: boost/asio/use_future.hpp
Convenience header: None
Class used to specify that an asynchronous operation should return a future.
template< typename Allocator = std::allocator<void>> class use_future_t
|
Name |
Description |
|---|---|
|
The allocator type. The allocator is used when constructing the std::promise object for a given asynchronous operation. |
|
Name |
Description |
|---|---|
|
Obtain allocator. |
|
|
Specify an alternate allocator. |
|
|
Construct using default-constructed allocator. Construct using specified allocator. |
The use_future_t
class is used to indicate that an asynchronous operation should return a
std::future object. A use_future_t
object may be passed
as a handler to an asynchronous operation, typically using the special value
boost::asio::use_future
. For example:
std::future<std::size_t> my_future = my_socket.async_read_some(my_buffer, boost::asio::use_future);
The initiating function (async_read_some in the above example) returns a future that will receive the result of the operation. If the operation completes with an error_code indicating failure, it is converted into a system_error and passed back to the caller via the future.
Header: boost/asio/use_future.hpp
Convenience header: None
The allocator type. The allocator is used when
constructing the std::promise
object for a given asynchronous
operation.
typedef Allocator allocator_type;
Header: boost/asio/use_future.hpp
Convenience header: None
Specify an alternate allocator.
template< typename OtherAllocator> use_future_t< OtherAllocator > operator[]( const OtherAllocator & allocator) const;
Construct using default-constructed allocator.
constexpr use_future_t(); » more...
Construct using specified allocator.
explicit use_future_t( const Allocator & allocator); » more...
Construct using default-constructed allocator.
constexpr use_future_t();
Construct using specified allocator.
use_future_t( const Allocator & allocator);
template< typename Service> Service & use_service( io_service & ios);
This function is used to locate a service object that corresponds to the
given service type. If there is no existing implementation of the service,
then the io_service
will create a new instance of the service.
The io_service
object that owns the service.
The service interface implementing the specified service type. Ownership of the service interface is not transferred to the caller.
Header: boost/asio/io_service.hpp
Convenience header: boost/asio.hpp
Wait traits suitable for use with the basic_waitable_timer
class template.
template< typename Clock> struct wait_traits
|
Name |
Description |
|---|---|
|
Convert a clock duration into a duration used for waiting. |
Header: boost/asio/wait_traits.hpp
Convenience header: boost/asio.hpp
Convert a clock duration into a duration used for waiting.
static Clock::duration to_wait_duration( const typename Clock::duration & d);
d
.
Default service implementation for a timer.
template< typename Clock, typename WaitTraits = boost::asio::wait_traits<Clock>> class waitable_timer_service : public io_service::service
|
Name |
Description |
|---|---|
|
The clock type. |
|
|
The duration type of the clock. |
|
|
The implementation type of the waitable timer. |
|
|
The time point type of the clock. |
|
|
The wait traits type. |
|
Name |
Description |
|---|---|
|
Cancel any asynchronous wait operations associated with the timer. |
|
|
Cancels one asynchronous wait operation associated with the timer. |
|
|
Construct a new timer implementation. |
|
|
Destroy a timer implementation. |
|
|
Get the expiry time for the timer as an absolute time. Set the expiry time for the timer as an absolute time. |
|
|
Get the expiry time for the timer relative to now. Set the expiry time for the timer relative to now. |
|
|
Get the io_service object that owns the service. |
|
|
Construct a new timer service for the specified io_service. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/waitable_timer_service.hpp
Convenience header: boost/asio.hpp
template< typename WaitHandler> void-or-deduced async_wait( implementation_type & impl, WaitHandler handler);
Cancel any asynchronous wait operations associated with the timer.
std::size_t cancel( implementation_type & impl, boost::system::error_code & ec);
Cancels one asynchronous wait operation associated with the timer.
std::size_t cancel_one( implementation_type & impl, boost::system::error_code & ec);
typedef Clock clock_type;
Header: boost/asio/waitable_timer_service.hpp
Convenience header: boost/asio.hpp
The duration type of the clock.
typedef clock_type::duration duration;
Header: boost/asio/waitable_timer_service.hpp
Convenience header: boost/asio.hpp
Get the expiry time for the timer as an absolute time.
time_point expires_at( const implementation_type & impl) const; » more...
Set the expiry time for the timer as an absolute time.
std::size_t expires_at( implementation_type & impl, const time_point & expiry_time, boost::system::error_code & ec); » more...
Get the expiry time for the timer as an absolute time.
time_point expires_at( const implementation_type & impl) const;
Set the expiry time for the timer as an absolute time.
std::size_t expires_at( implementation_type & impl, const time_point & expiry_time, boost::system::error_code & ec);
Get the expiry time for the timer relative to now.
duration expires_from_now( const implementation_type & impl) const; » more...
Set the expiry time for the timer relative to now.
std::size_t expires_from_now( implementation_type & impl, const duration & expiry_time, boost::system::error_code & ec); » more...
Get the expiry time for the timer relative to now.
duration expires_from_now( const implementation_type & impl) const;
Set the expiry time for the timer relative to now.
std::size_t expires_from_now( implementation_type & impl, const duration & expiry_time, boost::system::error_code & ec);
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
The implementation type of the waitable timer.
typedef implementation_defined implementation_type;
Header: boost/asio/waitable_timer_service.hpp
Convenience header: boost/asio.hpp
The time point type of the clock.
typedef clock_type::time_point time_point;
Header: boost/asio/waitable_timer_service.hpp
Convenience header: boost/asio.hpp
typedef WaitTraits traits_type;
Header: boost/asio/waitable_timer_service.hpp
Convenience header: boost/asio.hpp
void wait( implementation_type & impl, boost::system::error_code & ec);
Construct a new timer service
for the specified io_service
.
waitable_timer_service( boost::asio::io_service & io_service);
Provides Windows handle functionality.
template< typename HandleService> class basic_handle : public basic_io_object< HandleService >
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Construct a basic_handle without opening it. Construct a basic_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_handle from another. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
|
Protected destructor to prevent deletion through this type. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_handle
class template provides
the ability to wrap a Windows handle.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_handle.hpp
Convenience header: boost/asio.hpp
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle); » more... boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec); » more...
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle);
Assign an existing native handle to the handle.
boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec);
Construct a windows::basic_handle
without opening it.
explicit basic_handle( boost::asio::io_service & io_service); » more...
Construct a windows::basic_handle
on an existing native
handle.
basic_handle( boost::asio::io_service & io_service, const native_handle_type & handle); » more...
Move-construct a windows::basic_handle
from another.
basic_handle( basic_handle && other); » more...
Construct a windows::basic_handle
without opening
it.
basic_handle( boost::asio::io_service & io_service);
This constructor creates a handle without opening it.
The io_service
object that
the handle will use to dispatch handlers for any asynchronous operations
performed on the handle.
Construct a windows::basic_handle
on an existing
native handle.
basic_handle( boost::asio::io_service & io_service, const native_handle_type & handle);
This constructor creates a handle object to hold an existing native handle.
The io_service
object that
the handle will use to dispatch handlers for any asynchronous operations
performed on the handle.
A native handle.
Thrown on failure.
Move-construct a windows::basic_handle
from another.
basic_handle( basic_handle && other);
This constructor moves a handle from one object to another.
The other windows::basic_handle
object from
which the move will occur.
Following the move, the moved-from object is in the same state as if
constructed using the basic_handle(io_service&) constructor
.
Cancel all asynchronous operations associated with the handle.
void cancel(); » more... boost::system::error_code cancel( boost::system::error_code & ec); » more...
Cancel all asynchronous operations associated with the handle.
void cancel();
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Thrown on failure.
Cancel all asynchronous operations associated with the handle.
boost::system::error_code cancel( boost::system::error_code & ec);
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
void close(); » more... boost::system::error_code close( boost::system::error_code & ec); » more...
Close the handle.
void close();
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Thrown on failure.
Close the handle.
boost::system::error_code close( boost::system::error_code & ec);
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation(); » more... const implementation_type & get_implementation() const; » more...
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation();
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
const implementation_type & get_implementation() const;
Inherited from basic_io_object.
Get the io_service
associated with the
object.
boost::asio::io_service & get_io_service();
This function may be used to obtain the io_service
object that the I/O
object uses to dispatch handlers for asynchronous operations.
A reference to the io_service
object that the I/O
object will use to dispatch handlers. Ownership is not transferred to the
caller.
Get the service associated with the I/O object.
service_type & get_service(); » more... const service_type & get_service() const; » more...
Inherited from basic_io_object.
Get the service associated with the I/O object.
service_type & get_service();
Inherited from basic_io_object.
Get the service associated with the I/O object.
const service_type & get_service() const;
Inherited from basic_io_object.
(Deprecated: Use get_implementation()
.) The underlying implementation of the
I/O object.
implementation_type implementation;
Inherited from basic_io_object.
The underlying implementation type of I/O object.
typedef service_type::implementation_type implementation_type;
Header: boost/asio/windows/basic_handle.hpp
Convenience header: boost/asio.hpp
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer(); » more...
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const; » more...
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer();
This function returns a reference to the lowest layer in a stack of layers.
Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const;
This function returns a const reference to the lowest layer in a stack
of layers. Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A const reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
A windows::basic_handle
is always the lowest
layer.
typedef basic_handle< HandleService > lowest_layer_type;
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Construct a basic_handle without opening it. Construct a basic_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_handle from another. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
|
Protected destructor to prevent deletion through this type. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_handle
class template provides
the ability to wrap a Windows handle.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_handle.hpp
Convenience header: boost/asio.hpp
(Deprecated: Use native_handle()
.) Get the native handle representation.
native_type native();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
Get the native handle representation.
native_handle_type native_handle();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
The native representation of a handle.
typedef HandleService::native_handle_type native_handle_type;
Header: boost/asio/windows/basic_handle.hpp
Convenience header: boost/asio.hpp
(Deprecated: Use native_handle_type.) The native representation of a handle.
typedef HandleService::native_handle_type native_type;
Header: boost/asio/windows/basic_handle.hpp
Convenience header: boost/asio.hpp
Move-assign a windows::basic_handle
from another.
basic_handle & operator=( basic_handle && other);
This assignment operator moves a handle from one object to another.
The other windows::basic_handle
object from
which the move will occur.
Following the move, the moved-from object is in the same state as if constructed
using the basic_handle(io_service&) constructor
.
Inherited from basic_io_object.
(Deprecated: Use get_service()
.) The service associated with the I/O
object.
service_type & service;
Available only for services that do not support movability.
Inherited from basic_io_object.
The type of the service that will be used to provide I/O operations.
typedef HandleService service_type;
Header: boost/asio/windows/basic_handle.hpp
Convenience header: boost/asio.hpp
Provides object-oriented handle functionality.
template< typename ObjectHandleService = object_handle_service> class basic_object_handle : public windows::basic_handle< ObjectHandleService >
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Start an asynchronous wait on the object handle. |
|
|
Construct a basic_object_handle without opening it. Construct a basic_object_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_object_handle from another. |
|
|
Perform a blocking wait on the object handle. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_object_handle
class template
provides asynchronous and blocking object-oriented handle functionality.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_object_handle.hpp
Convenience header: boost/asio.hpp
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle); » more... boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle);
Inherited from windows::basic_handle.
Assign an existing native handle to the handle.
boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec);
Start an asynchronous wait on the object handle.
template< typename WaitHandler> void-or-deduced async_wait( WaitHandler handler);
This function is be used to initiate an asynchronous wait against the object handle. It always returns immediately.
The handler to be called when the object handle is set to the signalled state. Copies will be made of the handler as required. The function signature of the handler must be:
void handler( const boost::system::error_code& error // Result of operation. );
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 boost::asio::io_service::post()
.
Construct a windows::basic_object_handle
without opening
it.
explicit basic_object_handle( boost::asio::io_service & io_service); » more...
Construct a windows::basic_object_handle
on an existing
native handle.
basic_object_handle( boost::asio::io_service & io_service, const native_handle_type & native_handle); » more...
Move-construct a windows::basic_object_handle
from another.
basic_object_handle( basic_object_handle && other); » more...
Construct a windows::basic_object_handle
without
opening it.
basic_object_handle( boost::asio::io_service & io_service);
This constructor creates an object handle without opening it.
The io_service
object that
the object handle will use to dispatch handlers for any asynchronous
operations performed on the handle.
Construct a windows::basic_object_handle
on an existing
native handle.
basic_object_handle( boost::asio::io_service & io_service, const native_handle_type & native_handle);
This constructor creates an object handle object to hold an existing native handle.
The io_service
object that
the object handle will use to dispatch handlers for any asynchronous
operations performed on the handle.
The new underlying handle implementation.
Thrown on failure.
Move-construct a windows::basic_object_handle
from another.
basic_object_handle( basic_object_handle && other);
This constructor moves an object handle from one object to another.
The other windows::basic_object_handle
object
from which the move will occur.
Following the move, the moved-from object is in the same state as if
constructed using the basic_object_handle(io_service&) constructor
.
Cancel all asynchronous operations associated with the handle.
void cancel(); » more... boost::system::error_code cancel( boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Cancel all asynchronous operations associated with the handle.
void cancel();
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Thrown on failure.
Inherited from windows::basic_handle.
Cancel all asynchronous operations associated with the handle.
boost::system::error_code cancel( boost::system::error_code & ec);
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
void close(); » more... boost::system::error_code close( boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Close the handle.
void close();
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Thrown on failure.
Inherited from windows::basic_handle.
Close the handle.
boost::system::error_code close( boost::system::error_code & ec);
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation(); » more... const implementation_type & get_implementation() const; » more...
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation();
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
const implementation_type & get_implementation() const;
Inherited from basic_io_object.
Get the io_service
associated with the
object.
boost::asio::io_service & get_io_service();
This function may be used to obtain the io_service
object that the I/O
object uses to dispatch handlers for asynchronous operations.
A reference to the io_service
object that the I/O
object will use to dispatch handlers. Ownership is not transferred to the
caller.
Get the service associated with the I/O object.
service_type & get_service(); » more... const service_type & get_service() const; » more...
Inherited from basic_io_object.
Get the service associated with the I/O object.
service_type & get_service();
Inherited from basic_io_object.
Get the service associated with the I/O object.
const service_type & get_service() const;
Inherited from basic_io_object.
(Deprecated: Use get_implementation()
.)
The underlying implementation of the I/O object.
implementation_type implementation;
Inherited from basic_io_object.
The underlying implementation type of I/O object.
typedef service_type::implementation_type implementation_type;
Header: boost/asio/windows/basic_object_handle.hpp
Convenience header: boost/asio.hpp
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer(); » more...
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const; » more...
Inherited from windows::basic_handle.
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer();
This function returns a reference to the lowest layer in a stack of layers.
Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
Inherited from windows::basic_handle.
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const;
This function returns a const reference to the lowest layer in a stack
of layers. Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A const reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
Inherited from windows::basic_handle.
A windows::basic_handle
is always the lowest
layer.
typedef basic_handle< ObjectHandleService > lowest_layer_type;
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Construct a basic_handle without opening it. Construct a basic_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_handle from another. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
|
Protected destructor to prevent deletion through this type. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_handle
class template provides
the ability to wrap a Windows handle.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_object_handle.hpp
Convenience header: boost/asio.hpp
Inherited from windows::basic_handle.
(Deprecated: Use native_handle()
.) Get the native handle representation.
native_type native();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
Inherited from windows::basic_handle.
Get the native handle representation.
native_handle_type native_handle();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
The native representation of a handle.
typedef ObjectHandleService::native_handle_type native_handle_type;
Header: boost/asio/windows/basic_object_handle.hpp
Convenience header: boost/asio.hpp
Inherited from windows::basic_handle.
(Deprecated: Use native_handle_type.) The native representation of a handle.
typedef ObjectHandleService::native_handle_type native_type;
Header: boost/asio/windows/basic_object_handle.hpp
Convenience header: boost/asio.hpp
Move-assign a windows::basic_object_handle
from another.
basic_object_handle & operator=( basic_object_handle && other);
This assignment operator moves an object handle from one object to another.
The other windows::basic_object_handle
object
from which the move will occur.
Following the move, the moved-from object is in the same state as if constructed
using the basic_object_handle(io_service&) constructor
.
Inherited from basic_io_object.
(Deprecated: Use get_service()
.) The service associated with the I/O
object.
service_type & service;
Available only for services that do not support movability.
Inherited from basic_io_object.
The type of the service that will be used to provide I/O operations.
typedef ObjectHandleService service_type;
Header: boost/asio/windows/basic_object_handle.hpp
Convenience header: boost/asio.hpp
Perform a blocking wait on the object handle.
void wait(); » more... void wait( boost::system::error_code & ec); » more...
Perform a blocking wait on the object handle.
void wait();
This function is used to wait for the object handle to be set to the signalled state. This function blocks and does not return until the object handle has been set to the signalled state.
Thrown on failure.
Perform a blocking wait on the object handle.
void wait( boost::system::error_code & ec);
This function is used to wait for the object handle to be set to the signalled state. This function blocks and does not return until the object handle has been set to the signalled state.
Set to indicate what error occurred, if any.
Provides random-access handle functionality.
template< typename RandomAccessHandleService = random_access_handle_service> class basic_random_access_handle : public windows::basic_handle< RandomAccessHandleService >
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Start an asynchronous read at the specified offset. |
|
|
Start an asynchronous write at the specified offset. |
|
|
Construct a basic_random_access_handle without opening it. Construct a basic_random_access_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_random_access_handle from another. |
|
|
Read some data from the handle at the specified offset. |
|
|
Write some data to the handle at the specified offset. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_random_access_handle
class
template provides asynchronous and blocking random-access handle functionality.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_random_access_handle.hpp
Convenience header: boost/asio.hpp
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle); » more... boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle);
Inherited from windows::basic_handle.
Assign an existing native handle to the handle.
boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec);
Start an asynchronous read at the specified offset.
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_read_some_at( uint64_t offset, const MutableBufferSequence & buffers, ReadHandler handler);
This function is used to asynchronously read data from the random-access handle. The function call always returns immediately.
The offset at which the data will be read.
One or more buffers into which the data will be read. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.
The handler to be called when the read operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
void handler( const boost::system::error_code& 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 boost::asio::io_service::post()
.
The read operation may not read all of the requested number of bytes. Consider
using the async_read_at
function if you
need to ensure that the requested amount of data is read before the asynchronous
operation completes.
To read into a single data buffer use the buffer
function as follows:
handle.async_read_some_at(42, boost::asio::buffer(data, size), handler);
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
Start an asynchronous write at the specified offset.
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_write_some_at( uint64_t offset, const ConstBufferSequence & buffers, WriteHandler handler);
This function is used to asynchronously write data to the random-access handle. The function call always returns immediately.
The offset at which the data will be written.
One or more data buffers to be written to the handle. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.
The handler to be called when the write operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
void handler( const boost::system::error_code& 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 boost::asio::io_service::post()
.
The write operation may not transmit all of the data to the peer. Consider
using the async_write_at
function if you
need to ensure that all data is written before the asynchronous operation
completes.
To write a single data buffer use the buffer
function as follows:
handle.async_write_some_at(42, boost::asio::buffer(data, size), handler);
See the buffer
documentation for information on writing multiple buffers in one go, and
how to use it with arrays, boost::array or std::vector.
Construct
a windows::basic_random_access_handle
without
opening it.
explicit basic_random_access_handle( boost::asio::io_service & io_service); » more...
Construct a windows::basic_random_access_handle
on
an existing native handle.
basic_random_access_handle( boost::asio::io_service & io_service, const native_handle_type & handle); » more...
Move-construct a windows::basic_random_access_handle
from
another.
basic_random_access_handle( basic_random_access_handle && other); » more...
Construct a windows::basic_random_access_handle
without
opening it.
basic_random_access_handle( boost::asio::io_service & io_service);
This constructor creates a random-access handle without opening it. The handle needs to be opened before data can be written to or read from it.
The io_service
object that
the random-access handle will use to dispatch handlers for any
asynchronous operations performed on the handle.
Construct a windows::basic_random_access_handle
on
an existing native handle.
basic_random_access_handle( boost::asio::io_service & io_service, const native_handle_type & handle);
This constructor creates a random-access handle object to hold an existing native handle.
The io_service
object that
the random-access handle will use to dispatch handlers for any
asynchronous operations performed on the handle.
The new underlying handle implementation.
Thrown on failure.
Move-construct a windows::basic_random_access_handle
from
another.
basic_random_access_handle( basic_random_access_handle && other);
This constructor moves a random-access handle from one object to another.
The other windows::basic_random_access_handle
object from which the move will occur.
Following the move, the moved-from object is in the same state as if
constructed using the basic_random_access_handle(io_service&)
constructor.
Cancel all asynchronous operations associated with the handle.
void cancel(); » more... boost::system::error_code cancel( boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Cancel all asynchronous operations associated with the handle.
void cancel();
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Thrown on failure.
Inherited from windows::basic_handle.
Cancel all asynchronous operations associated with the handle.
boost::system::error_code cancel( boost::system::error_code & ec);
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
void close(); » more... boost::system::error_code close( boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Close the handle.
void close();
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Thrown on failure.
Inherited from windows::basic_handle.
Close the handle.
boost::system::error_code close( boost::system::error_code & ec);
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation(); » more... const implementation_type & get_implementation() const; » more...
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation();
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
const implementation_type & get_implementation() const;
Inherited from basic_io_object.
Get the io_service
associated with the
object.
boost::asio::io_service & get_io_service();
This function may be used to obtain the io_service
object that the I/O
object uses to dispatch handlers for asynchronous operations.
A reference to the io_service
object that the I/O
object will use to dispatch handlers. Ownership is not transferred to the
caller.
Get the service associated with the I/O object.
service_type & get_service(); » more... const service_type & get_service() const; » more...
Inherited from basic_io_object.
Get the service associated with the I/O object.
service_type & get_service();
Inherited from basic_io_object.
Get the service associated with the I/O object.
const service_type & get_service() const;
Inherited from basic_io_object.
(Deprecated: Use get_implementation()
.)
The underlying implementation of the I/O object.
implementation_type implementation;
Inherited from basic_io_object.
The underlying implementation type of I/O object.
typedef service_type::implementation_type implementation_type;
Header: boost/asio/windows/basic_random_access_handle.hpp
Convenience header: boost/asio.hpp
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer(); » more...
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const; » more...
Inherited from windows::basic_handle.
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer();
This function returns a reference to the lowest layer in a stack of layers.
Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
Inherited from windows::basic_handle.
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const;
This function returns a const reference to the lowest layer in a stack
of layers. Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A const reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
Inherited from windows::basic_handle.
A windows::basic_handle
is always the lowest
layer.
typedef basic_handle< RandomAccessHandleService > lowest_layer_type;
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Construct a basic_handle without opening it. Construct a basic_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_handle from another. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
|
Protected destructor to prevent deletion through this type. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_handle
class template provides
the ability to wrap a Windows handle.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_random_access_handle.hpp
Convenience header: boost/asio.hpp
Inherited from windows::basic_handle.
(Deprecated: Use native_handle()
.)
Get the native handle representation.
native_type native();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
Inherited from windows::basic_handle.
Get the native handle representation.
native_handle_type native_handle();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
The native representation of a handle.
typedef RandomAccessHandleService::native_handle_type native_handle_type;
Header: boost/asio/windows/basic_random_access_handle.hpp
Convenience header: boost/asio.hpp
(Deprecated: Use native_handle_type.) The native representation of a handle.
typedef RandomAccessHandleService::native_handle_type native_type;
Header: boost/asio/windows/basic_random_access_handle.hpp
Convenience header: boost/asio.hpp
Move-assign a windows::basic_random_access_handle
from
another.
basic_random_access_handle & operator=( basic_random_access_handle && other);
This assignment operator moves a random-access handle from one object to another.
The other windows::basic_random_access_handle
object from which the move will occur.
Following the move, the moved-from object is in the same state as if constructed
using the basic_random_access_handle(io_service&)
constructor.
Read some data from the handle at the specified offset.
template< typename MutableBufferSequence> std::size_t read_some_at( uint64_t offset, const MutableBufferSequence & buffers); » more... template< typename MutableBufferSequence> std::size_t read_some_at( uint64_t offset, const MutableBufferSequence & buffers, boost::system::error_code & ec); » more...
Read some data from the handle at the specified offset.
template< typename MutableBufferSequence> std::size_t read_some_at( uint64_t offset, const MutableBufferSequence & buffers);
This function is used to read data from the random-access handle. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
The offset at which the data will be read.
One or more buffers into which the data will be read.
The number of bytes read.
Thrown on failure. An error code of boost::asio::error::eof
indicates that the connection was closed by the peer.
The read_some operation may not read all of the requested number of bytes.
Consider using the read_at
function if you need
to ensure that the requested amount of data is read before the blocking
operation completes.
To read into a single data buffer use the buffer
function as follows:
handle.read_some_at(42, boost::asio::buffer(data, size));
See the buffer
documentation for information on reading into multiple buffers in one
go, and how to use it with arrays, boost::array or std::vector.
Read some data from the handle at the specified offset.
template< typename MutableBufferSequence> std::size_t read_some_at( uint64_t offset, const MutableBufferSequence & buffers, boost::system::error_code & ec);
This function is used to read data from the random-access handle. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
The offset at which the data will be read.
One or more buffers into which the data will be read.
Set to indicate what error occurred, if any.
The number of bytes read. Returns 0 if an error occurred.
The read_some operation may not read all of the requested number of bytes.
Consider using the read_at
function if you need
to ensure that the requested amount of data is read before the blocking
operation completes.
Inherited from basic_io_object.
(Deprecated: Use get_service()
.)
The service associated with the I/O object.
service_type & service;
Available only for services that do not support movability.
Inherited from basic_io_object.
The type of the service that will be used to provide I/O operations.
typedef RandomAccessHandleService service_type;
Header: boost/asio/windows/basic_random_access_handle.hpp
Convenience header: boost/asio.hpp
Write some data to the handle at the specified offset.
template< typename ConstBufferSequence> std::size_t write_some_at( uint64_t offset, const ConstBufferSequence & buffers); » more... template< typename ConstBufferSequence> std::size_t write_some_at( uint64_t offset, const ConstBufferSequence & buffers, boost::system::error_code & ec); » more...
Write some data to the handle at the specified offset.
template< typename ConstBufferSequence> std::size_t write_some_at( uint64_t offset, const ConstBufferSequence & buffers);
This function is used to write data to the random-access handle. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
The offset at which the data will be written.
One or more data buffers to be written to the handle.
The number of bytes written.
Thrown on failure. An error code of boost::asio::error::eof
indicates that the connection was closed by the peer.
The write_some_at operation may not write all of the data. Consider using
the write_at
function if you need to ensure that all data is written before the blocking
operation completes.
To write a single data buffer use the buffer
function as follows:
handle.write_some_at(42, boost::asio::buffer(data, size));
See the buffer
documentation for information on writing multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
Write some data to the handle at the specified offset.
template< typename ConstBufferSequence> std::size_t write_some_at( uint64_t offset, const ConstBufferSequence & buffers, boost::system::error_code & ec);
This function is used to write data to the random-access handle. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
The offset at which the data will be written.
One or more data buffers to be written to the handle.
Set to indicate what error occurred, if any.
The number of bytes written. Returns 0 if an error occurred.
The write_some operation may not transmit all of the data to the peer.
Consider using the write_at
function if you need
to ensure that all data is written before the blocking operation completes.
Provides stream-oriented handle functionality.
template< typename StreamHandleService = stream_handle_service> class basic_stream_handle : public windows::basic_handle< StreamHandleService >
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Start an asynchronous read. |
|
|
Start an asynchronous write. |
|
|
Construct a basic_stream_handle without opening it. Construct a basic_stream_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_stream_handle from another. |
|
|
Read some data from the handle. |
|
|
Write some data to the handle. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_stream_handle
class template
provides asynchronous and blocking stream-oriented handle functionality.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_stream_handle.hpp
Convenience header: boost/asio.hpp
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle); » more... boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Assign an existing native handle to the handle.
void assign( const native_handle_type & handle);
Inherited from windows::basic_handle.
Assign an existing native handle to the handle.
boost::system::error_code assign( const native_handle_type & handle, boost::system::error_code & ec);
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_read_some( const MutableBufferSequence & buffers, ReadHandler handler);
This function is used to asynchronously read data from the stream handle. The function call always returns immediately.
One or more buffers into which the data will be read. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.
The handler to be called when the read operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
void handler( const boost::system::error_code& 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 boost::asio::io_service::post()
.
The read operation may not read all of the requested number of bytes. Consider
using the async_read
function if you need
to ensure that the requested amount of data is read before the asynchronous
operation completes.
To read into a single data buffer use the buffer
function as follows:
handle.async_read_some(boost::asio::buffer(data, size), handler);
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_write_some( const ConstBufferSequence & buffers, WriteHandler handler);
This function is used to asynchronously write data to the stream handle. The function call always returns immediately.
One or more data buffers to be written to the handle. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.
The handler to be called when the write operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
void handler( const boost::system::error_code& 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 boost::asio::io_service::post()
.
The write operation may not transmit all of the data to the peer. Consider
using the async_write
function if you need
to ensure that all data is written before the asynchronous operation completes.
To write a single data buffer use the buffer
function as follows:
handle.async_write_some(boost::asio::buffer(data, size), handler);
See the buffer
documentation for information on writing multiple buffers in one go, and
how to use it with arrays, boost::array or std::vector.
Construct a windows::basic_stream_handle
without opening
it.
explicit basic_stream_handle( boost::asio::io_service & io_service); » more...
Construct a windows::basic_stream_handle
on an existing
native handle.
basic_stream_handle( boost::asio::io_service & io_service, const native_handle_type & handle); » more...
Move-construct a windows::basic_stream_handle
from another.
basic_stream_handle( basic_stream_handle && other); » more...
Construct a windows::basic_stream_handle
without
opening it.
basic_stream_handle( boost::asio::io_service & io_service);
This constructor creates a stream handle without opening it. The handle needs to be opened and then connected or accepted before data can be sent or received on it.
The io_service
object that
the stream handle will use to dispatch handlers for any asynchronous
operations performed on the handle.
Construct a windows::basic_stream_handle
on an existing
native handle.
basic_stream_handle( boost::asio::io_service & io_service, const native_handle_type & handle);
This constructor creates a stream handle object to hold an existing native handle.
The io_service
object that
the stream handle will use to dispatch handlers for any asynchronous
operations performed on the handle.
The new underlying handle implementation.
Thrown on failure.
Move-construct a windows::basic_stream_handle
from another.
basic_stream_handle( basic_stream_handle && other);
This constructor moves a stream handle from one object to another.
The other windows::basic_stream_handle
object
from which the move will occur.
Following the move, the moved-from object is in the same state as if
constructed using the basic_stream_handle(io_service&) constructor
.
Cancel all asynchronous operations associated with the handle.
void cancel(); » more... boost::system::error_code cancel( boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Cancel all asynchronous operations associated with the handle.
void cancel();
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Thrown on failure.
Inherited from windows::basic_handle.
Cancel all asynchronous operations associated with the handle.
boost::system::error_code cancel( boost::system::error_code & ec);
This function causes all outstanding asynchronous read or write operations
to finish immediately, and the handlers for cancelled operations will
be passed the boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
void close(); » more... boost::system::error_code close( boost::system::error_code & ec); » more...
Inherited from windows::basic_handle.
Close the handle.
void close();
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Thrown on failure.
Inherited from windows::basic_handle.
Close the handle.
boost::system::error_code close( boost::system::error_code & ec);
This function is used to close the handle. Any asynchronous read or write
operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
Set to indicate what error occurred, if any.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation(); » more... const implementation_type & get_implementation() const; » more...
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
implementation_type & get_implementation();
Inherited from basic_io_object.
Get the underlying implementation of the I/O object.
const implementation_type & get_implementation() const;
Inherited from basic_io_object.
Get the io_service
associated with the
object.
boost::asio::io_service & get_io_service();
This function may be used to obtain the io_service
object that the I/O
object uses to dispatch handlers for asynchronous operations.
A reference to the io_service
object that the I/O
object will use to dispatch handlers. Ownership is not transferred to the
caller.
Get the service associated with the I/O object.
service_type & get_service(); » more... const service_type & get_service() const; » more...
Inherited from basic_io_object.
Get the service associated with the I/O object.
service_type & get_service();
Inherited from basic_io_object.
Get the service associated with the I/O object.
const service_type & get_service() const;
Inherited from basic_io_object.
(Deprecated: Use get_implementation()
.)
The underlying implementation of the I/O object.
implementation_type implementation;
Inherited from basic_io_object.
The underlying implementation type of I/O object.
typedef service_type::implementation_type implementation_type;
Header: boost/asio/windows/basic_stream_handle.hpp
Convenience header: boost/asio.hpp
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer(); » more...
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const; » more...
Inherited from windows::basic_handle.
Get a reference to the lowest layer.
lowest_layer_type & lowest_layer();
This function returns a reference to the lowest layer in a stack of layers.
Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
Inherited from windows::basic_handle.
Get a const reference to the lowest layer.
const lowest_layer_type & lowest_layer() const;
This function returns a const reference to the lowest layer in a stack
of layers. Since a windows::basic_handle
cannot contain
any further layers, it simply returns a reference to itself.
A const reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
Inherited from windows::basic_handle.
A windows::basic_handle
is always the lowest
layer.
typedef basic_handle< StreamHandleService > lowest_layer_type;
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_handle is always the lowest layer. |
|
|
The native representation of a handle. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a handle. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native handle to the handle. |
|
|
Construct a basic_handle without opening it. Construct a basic_handle on an existing native handle.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native handle representation. |
|
|
Get the native handle representation. |
|
|
Move-assign a basic_handle from another. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
|
Protected destructor to prevent deletion through this type. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The windows::basic_handle
class template provides
the ability to wrap a Windows handle.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/windows/basic_stream_handle.hpp
Convenience header: boost/asio.hpp
Inherited from windows::basic_handle.
(Deprecated: Use native_handle()
.) Get the native handle representation.
native_type native();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
Inherited from windows::basic_handle.
Get the native handle representation.
native_handle_type native_handle();
This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.
The native representation of a handle.
typedef StreamHandleService::native_handle_type native_handle_type;
Header: boost/asio/windows/basic_stream_handle.hpp
Convenience header: boost/asio.hpp
(Deprecated: Use native_handle_type.) The native representation of a handle.
typedef StreamHandleService::native_handle_type native_type;
Header: boost/asio/windows/basic_stream_handle.hpp
Convenience header: boost/asio.hpp
Move-assign a windows::basic_stream_handle
from another.
basic_stream_handle & operator=( basic_stream_handle && other);
This assignment operator moves a stream handle from one object to another.
The other windows::basic_stream_handle
object
from which the move will occur.
Following the move, the moved-from object is in the same state as if constructed
using the basic_stream_handle(io_service&) constructor
.
Read some data from the handle.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers); » more... template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers, boost::system::error_code & ec); » more...
Read some data from the handle.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers);
This function is used to read data from the stream handle. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
One or more buffers into which the data will be read.
The number of bytes read.
Thrown on failure. An error code of boost::asio::error::eof
indicates that the connection was closed by the peer.
The read_some operation may not read all of the requested number of bytes.
Consider using the read
function if you need to
ensure that the requested amount of data is read before the blocking
operation completes.
To read into a single data buffer use the buffer
function as follows:
handle.read_some(boost::asio::buffer(data, size));
See the buffer
documentation for information on reading into multiple buffers in one
go, and how to use it with arrays, boost::array or std::vector.
Read some data from the handle.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers, boost::system::error_code & ec);
This function is used to read data from the stream handle. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
One or more buffers into which the data will be read.
Set to indicate what error occurred, if any.
The number of bytes read. Returns 0 if an error occurred.
The read_some operation may not read all of the requested number of bytes.
Consider using the read
function if you need to
ensure that the requested amount of data is read before the blocking
operation completes.
Inherited from basic_io_object.
(Deprecated: Use get_service()
.) The service associated with the I/O
object.
service_type & service;
Available only for services that do not support movability.
Inherited from basic_io_object.
The type of the service that will be used to provide I/O operations.
typedef StreamHandleService service_type;
Header: boost/asio/windows/basic_stream_handle.hpp
Convenience header: boost/asio.hpp
Write some data to the handle.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers); » more... template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers, boost::system::error_code & ec); » more...
Write some data to the handle.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers);
This function is used to write data to the stream handle. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
One or more data buffers to be written to the handle.
The number of bytes written.
Thrown on failure. An error code of boost::asio::error::eof