#pragma once #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; boost::asio::ip::tcp::endpoint 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() { return endpoint.address(); } /*! * \brief bind_v6_and_v4_any * \param accept_handler Function to call when accepting an incoming connection. * * 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); /*! * \brief setup_listen_socket * \param accept_handler Function to call when accepting an incoming connection. */ void setup_listen_socket(std::function accept_handler); };