#pragma once #include "accept.hpp" #include #include #include /*! * \file */ /*! * \brief The Acceptor class * * Encapsulates an endpoint and an acceptor. * Otherwise they would be side to side in the Server class. */ class Acceptor{ boost::asio::ip::tcp::acceptor acceptor; ///< The acceptor boost::asio::ip::tcp::endpoint endpoint; ///< The endpoint public: /*! * \brief Acceptor * \param io_service The io_service to associate with * \param address The listen address * \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(); /*! * \brief is_open Checks if the acceptor socket is opened. * \return true if the socket is open, false otherwise. */ bool is_open(); /*! * \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 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 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 start_accepting(std::shared_ptr ctx, SSLAcceptHandler accept_handler); };