aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/apps/apps.h1
-rw-r--r--src/apps/tls_server_asio.cpp (renamed from doc/examples/asio_tls_server.cpp)19
-rw-r--r--src/build-data/makefile/unix_shr.in2
3 files changed, 14 insertions, 8 deletions
diff --git a/src/apps/apps.h b/src/apps/apps.h
index 18a25b935..ae4f884b6 100644
--- a/src/apps/apps.h
+++ b/src/apps/apps.h
@@ -26,4 +26,5 @@ DEFINE_EXAMPLE(read_ssh);
DEFINE_EXAMPLE(self_sig);
DEFINE_EXAMPLE(tls_client);
DEFINE_EXAMPLE(tls_server);
+DEFINE_EXAMPLE(tls_server_asio);
DEFINE_EXAMPLE(x509);
diff --git a/doc/examples/asio_tls_server.cpp b/src/apps/tls_server_asio.cpp
index 0a5aac7a3..119e2154f 100644
--- a/doc/examples/asio_tls_server.cpp
+++ b/src/apps/tls_server_asio.cpp
@@ -1,3 +1,4 @@
+#include "apps.h"
#include <iostream>
#include <string>
#include <vector>
@@ -19,6 +20,8 @@
using Botan::byte;
using boost::asio::ip::tcp;
+namespace {
+
class tls_server_session : public boost::enable_shared_from_this<tls_server_session>
{
public:
@@ -198,12 +201,12 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
std::vector<byte> m_client_data;
};
-class tls_server
+class asio_tls_server
{
public:
typedef tls_server_session session;
- tls_server(boost::asio::io_service& io_service, unsigned short port) :
+ asio_tls_server(boost::asio::io_service& io_service, unsigned short port) :
m_acceptor(io_service, tcp::endpoint(tcp::v4(), port)),
m_session_manager(m_rng),
m_creds(m_rng)
@@ -213,7 +216,7 @@ class tls_server
m_acceptor.async_accept(
new_session->socket(),
boost::bind(
- &tls_server::handle_accept,
+ &asio_tls_server::handle_accept,
this,
new_session,
boost::asio::placeholders::error)
@@ -244,7 +247,7 @@ class tls_server
m_acceptor.async_accept(
new_session->socket(),
boost::bind(
- &tls_server::handle_accept,
+ &asio_tls_server::handle_accept,
this,
new_session,
boost::asio::placeholders::error)
@@ -270,15 +273,17 @@ size_t choose_thread_count()
return 2;
}
-int main(int argc, char* argv[])
+}
+
+int tls_server_asio(int argc, char* argv[])
{
try
{
Botan::LibraryInitializer init("thread_safe=true");
boost::asio::io_service io_service;
- unsigned short port = 4434;
- tls_server server(io_service, port);
+ const unsigned short port = 4434;
+ asio_tls_server server(io_service, port);
size_t num_threads = choose_thread_count();
if(argc == 2)
diff --git a/src/build-data/makefile/unix_shr.in b/src/build-data/makefile/unix_shr.in
index 53974c4ff..ccbbd6706 100644
--- a/src/build-data/makefile/unix_shr.in
+++ b/src/build-data/makefile/unix_shr.in
@@ -70,7 +70,7 @@ APPOBJS = %{app_objs}
# Link Commands
$(APP): $(LIBRARIES) $(APPOBJS)
- $(CXX) $(LDFLAGS) $(APPOBJS) $(SHARED_LIB) $(LINK_TO) -lboost_regex -o $(APP)
+ $(CXX) $(LDFLAGS) $(APPOBJS) $(SHARED_LIB) $(LINK_TO) -lboost_regex -lboost_thread -o $(APP)
$(STATIC_LIB): $(LIBOBJS)
$(RM) $(STATIC_LIB)