diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-29 14:26:07 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-29 14:26:07 +0200 |
| commit | 8507aec59b92e16ed6a05c92fea6ced5dba3f753 (patch) | |
| tree | b8ae5904f74c9896ccc6662837e628400d47b829 /libcmix-network/acceptor.hpp | |
| parent | 3fe7a5b6a18b6841ae51f294dc58fe9c8df6d375 (diff) | |
| download | cmix-8507aec59b92e16ed6a05c92fea6ced5dba3f753.tar.gz cmix-8507aec59b92e16ed6a05c92fea6ced5dba3f753.tar.bz2 cmix-8507aec59b92e16ed6a05c92fea6ced5dba3f753.zip | |
Added some boilerplate to enable ssl connections.
Diffstat (limited to 'libcmix-network/acceptor.hpp')
| -rw-r--r-- | libcmix-network/acceptor.hpp | 47 |
1 files changed, 37 insertions, 10 deletions
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 <boost/asio/ip/tcp.hpp> +#include <boost/asio/ssl.hpp> #include <functional> @@ -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<void(boost::asio::ip::tcp::socket&&)> 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<void(boost::asio::ip::tcp::socket&&)> accept_handler); + void start_accepting(std::shared_ptr<boost::asio::ssl::context> ctx, SSLAcceptHandler accept_handler); + }; |
