启动异步 SSL 握手。
template< typename ConstBufferSequence, typename BufferedHandshakeToken = default_completion_token_t<executor_type>> DEDUCED async_handshake( handshake_type type, const ConstBufferSequence & buffers, BufferedHandshakeToken && token = default_completion_token_t< executor_type >(), constraint_t< is_const_buffer_sequence< ConstBufferSequence >::value > = 0);
此函数用于在流上异步执行 SSL 握手。它是一个异步操作的起始函数,并且始终立即返回。
要执行的握手类型,即作为客户端或作为服务器。
用于重用握手的缓冲数据。尽管 buffer 对象可以根据需要进行复制,但底层缓冲区的拥有权仍由调用者保留,调用者必须确保在调用完成处理程序之前这些缓冲区保持有效。
用于生成完成处理程序的完成令牌,该处理程序将在握手完成后被调用。可能的完成令牌包括 use_future
、use_awaitable
、yield_context
,或具有正确完成签名的函数对象。完成处理程序的函数签名必须是
void handler( const boost::system::error_code& error, // Result of operation. std::size_t bytes_transferred // Amount of buffers used in handshake. );
无论异步操作是立即完成还是未立即完成,完成处理程序都不会在此函数内部被调用。在立即完成的情况下,处理程序的调用将以等同于使用 async_immediate
的方式执行。
void(boost::system::error_code, std::size_t)
此异步操作支持以下 cancellation_type
值的取消
cancellation_type::terminal
cancellation_type::partial
如果它们也被 Stream
类型的 async_read_some
和 async_write_some
操作支持。