From 8507aec59b92e16ed6a05c92fea6ced5dba3f753 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Thu, 29 Sep 2016 14:26:07 +0200 Subject: Added some boilerplate to enable ssl connections. --- libcmix-network/acceptor.hpp | 47 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'libcmix-network/acceptor.hpp') diff --git a/libcmix-network/acceptor.hpp b/libcmix-network/acceptor.hpp index 06b709d..6e4de63 100644 --- a/libcmix-network/acceptor.hpp +++ b/libcmix-network/acceptor.hpp @@ -1,6 +1,9 @@ #pragma once +#include "accept.hpp" + #include +#include #include @@ -15,8 +18,8 @@ * Otherwise they would be side to side in the Server class. */ class Acceptor{ - boost::asio::ip::tcp::acceptor acceptor; - boost::asio::ip::tcp::endpoint endpoint; + boost::asio::ip::tcp::acceptor acceptor; ///< The acceptor + boost::asio::ip::tcp::endpoint endpoint; ///< The endpoint public: /*! @@ -26,25 +29,49 @@ public: * \param port The listen port */ Acceptor(boost::asio::io_service& io_service, boost::asio::ip::address address, uint16_t port); - + /*! * \brief get_address * \return The listening address */ - boost::asio::ip::address get_address() { return endpoint.address(); } + boost::asio::ip::address get_address(); + + /*! + * \brief is_open Checks if the acceptor socket is opened. + * \return true if the socket is open, false otherwise. + */ + bool is_open(); /*! - * \brief bind_v6_and_v4_any - * \param accept_handler Function to call when accepting an incoming connection. + * \brief listen_v6_and_v4_any * * If you want to accept on both ipv6 and ipv any you have to do some special setup. * This function handles that and starts listening. */ - void bind_v6_and_v4_any(std::function accept_handler); + void listen_v6_and_v4_any(); + + /*! + * \brief listen_socket + * + * start listening on the specified endpoint + */ + void listen_socket(); + + /*! + * \brief start_accepting + * \param accept_handler The function called on a succesful accepted connection. + * + * Asynchronously indefinitely accepts connections. + */ + void start_accepting(AcceptHandler accept_handler); /*! - * \brief setup_listen_socket - * \param accept_handler Function to call when accepting an incoming connection. + * \brief start_accepting + * \param ctx The SSL context + * \param accept_handler The function called on a succesful accepted ssl connection. + * + * Asynchronously indefinitely accepts SSL connections. */ - void setup_listen_socket(std::function accept_handler); + void start_accepting(std::shared_ptr ctx, SSLAcceptHandler accept_handler); + }; -- cgit v1.2.3-70-g09d2