diff options
Diffstat (limited to 'libcmix-network/accept.hpp')
| -rw-r--r-- | libcmix-network/accept.hpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libcmix-network/accept.hpp b/libcmix-network/accept.hpp new file mode 100644 index 0000000..dde98a3 --- /dev/null +++ b/libcmix-network/accept.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include <boost/asio/ip/tcp.hpp> +#include <boost/asio/ssl.hpp> + +#include <memory> + +/*! + * \file + */ + +/*! + * \brief AcceptHandler Handy typedef for a function taking an tcp::socket. + */ +typedef std::function<void(boost::asio::ip::tcp::socket&&)> AcceptHandler; +/*! + * \brief SSLAcceptHandler Handy typedef for a function taking an "SSLSocket" + */ +typedef std::function<void(boost::asio::ssl::stream<boost::asio::ip::tcp::socket>&&)> SSLAcceptHandler; + +/*! + * \brief accept_loop Keeps accepting connections on the specified acceptor + * \param acceptor The acceptor should be in the listening state. + * \param f A callback function called with the accepted connection. + * + * The io_service of the acceptor is used as the io_service for the newly created socket. + */ +void accept_loop(boost::asio::ip::tcp::acceptor& acceptor, AcceptHandler f); + +/*! + * \brief accept_loop Keeps accepting SSL connections on the specified acceptor + * \param acceptor The acceptor should be in listening state. + * \param ctx The SSL context + * \param f A callback function called with the accepted connection. + * + * The io_service of the acceptor is used as the io_service for the newly created socket. + */ +void accept_loop(boost::asio::ip::tcp::acceptor& acceptor, std::shared_ptr<boost::asio::ssl::context> ctx, SSLAcceptHandler f);
\ No newline at end of file |
