This article talks about c++ Botan::TLS::Stream Constructors (overload).
template <typename... Args> explicit Stream( std::shared_ptr<Context> context, std::shared_ptr<StreamCallbacks> callbacks, Args && ... args );
template <class StreamLayer, class ChannelT = Channel> class Stream { ... ... StreamLayer m_nextLayer; };
c++ Example:
auto tls_context = std::make_shared<Botan::TLS::Context>( cred, rng, ses, policy, server_info); auto callbacks = std::make_shared<Botan::TLS::StreamCallbacks>(); boost::asio::thread_pool thread_pool; Boan::TLS::Stream<boost::beast::tcp_stream> tls_stream{ tls_context, callbacks, thread_pool.get_executor() };
![]() |
Note |
|---|---|
Distinguish class template and constructor template. |
template <typename... Args> explicit Stream(std::shared_ptr<Context> context, Args&&... args);
Propagate from constructor 02 to constructor 01:
template <typename Arg> explicit Stream( Arg&& arg, std::shared_ptr<Context> context, std::shared_ptr<StreamCallbacks> callbacks = std::make_shared<StreamCallbacks>() );
Propagate from constructor 03 to constructor 01:
Please note that
arg is single arg;
args
... are many args.
This constructor is for compatibility, not suggested.
Example:
// Work, but not suggested: Botan::TLS::Stream tls_stream1{io_context, tls_context}; // Work, highly suggested: Botan::TLS::Stream tls_stream2{tls_context, io_context};
template <typename... Args> explicit Stream( Server_Information server_info, Args&&... args ): Stream{ std::make_shared<Context>(std::move(server_info)), std::forward<Args>(args)... } {}
By this constructor, it will construct a simple Botan::TLS::Context shared pointer object with server_info parameter only.
I think the constructed tls-context by this constructor does not work in many
realistic Internet environment.
To make a fully working tls-context and tls-stream, do not use this constructor.
Constructor 01 and constructor
02 are reommended,
constructor 03 and constructor 04 are not reommended.
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
Sun Jun 28 11:01:14 AM UTC 2026
//////////////////////////////////////////////////////////////////////
+
Github:
https://github.com/cppfx/cpphtgt
+
Powered by:
B2 Build
| boost quickbook
+
+