Skip to content

Commit

Permalink
Mention boost_compat.h in the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
reneme committed Oct 25, 2023
1 parent 315c375 commit bdb44d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
8 changes: 7 additions & 1 deletion doc/api_ref/tls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,13 @@ TLS Stream

:cpp:class:`TLS::Stream` offers a Boost.Asio compatible wrapper around :cpp:class:`TLS::Client` and :cpp:class:`TLS::Server`.
It can be used as an alternative to Boost.Asio's `ssl::stream <https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/reference/ssl__stream.html>`_ with minor adjustments to the using code.
It offers the following interface:

To use the asio stream wrapper, a relatively recent version of boost is required.
Include ``botan/boost_compat.h`` and check that ``BOTAN_FOUND_COMPATIBLE_BOOST_VERSION``
is defined before including ``botan/asio_stream.h`` to be ensure compatibility at
compile time of your application.

The asio Stream offers the following interface:

.. cpp:class:: template <class StreamLayer, class ChannelT> TLS::Stream

Expand Down
28 changes: 20 additions & 8 deletions src/examples/tls_stream_client.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#include <iostream>

#include <botan/asio_stream.h>
#include <botan/auto_rng.h>
#include <botan/certstor_system.h>
#include <botan/tls.h>
#include <botan/boost_compat.h>
#if defined(BOTAN_FOUND_COMPATIBLE_BOOST_VERSION)

#include <boost/asio.hpp>
#include <boost/beast.hpp>
#include <boost/bind.hpp>
#include <utility>
#include <botan/asio_stream.h>
#include <botan/auto_rng.h>
#include <botan/certstor_system.h>
#include <botan/tls.h>

#include <boost/asio.hpp>
#include <boost/beast.hpp>
#include <boost/bind.hpp>
#include <utility>

namespace http = boost::beast::http;
namespace ap = boost::asio::placeholders;
Expand Down Expand Up @@ -113,3 +116,12 @@ int main() {

return 0;
}

#else

int main() {
std::cout << "Your boost version is too old, sorry.\n";
return 1;
}

#endif

0 comments on commit bdb44d8

Please sign in to comment.