From d03c826429ac8dea4b1ea56e2f00dfe982779765 Mon Sep 17 00:00:00 2001 From: Doralitze <doralitze@chaotikum.org> Date: Sat, 24 Jul 2021 17:50:17 +0200 Subject: [PATCH] add: Async server socket documentation --- src/net/async_server.hpp | 41 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/net/async_server.hpp b/src/net/async_server.hpp index 02bf71f..52799b9 100644 --- a/src/net/async_server.hpp +++ b/src/net/async_server.hpp @@ -9,6 +9,17 @@ namespace rmrf::net { +/** + * This class handles raw server sockets and wrapps them with automatic + * resource management functions. This class is an internal helper class + * utilized by classes like the TCP Server and thus shouldn't be used directly. + * @class async_server_socket + * @author leondietrich + * @date 14/07/21 + * @file async_server.hpp + * @brief An asynchronous server socket handler. + * @see rmrf::net::tcp_server_socket + */ class async_server_socket : public std::enable_shared_from_this<async_server_socket> { public: typedef std::shared_ptr<async_server_socket> self_ptr_type; @@ -25,11 +36,37 @@ private: ::ev::io io; public: + + /** + * This constructor accepts your given file descriptor to the operating systems socket. + * @param fd A handle to the socket in form of an auto_fd + */ async_server_socket(auto_fd &&fd); + + /** + * This deconstructor automatically unregisteres the socket from libev which in turn automatically removes it from + * the watch list of active sockets. However this does not close the socket in the kernels perspective so you must + * use always auto_fd. + * @brief Automatically unregister the socket from libev + */ ~async_server_socket(); - accept_handler_type get_accept_handler() const; - void set_accept_handler(const accept_handler_type &value); + /** + * This method will return the currently used connection acceptance handler. + * Be aware that it will return an invalid state unless you used set_accept_handler + * prior to calling this method. + * @brief get the current registered accept handler + * @return The current accept handler + */ + accept_handler_type get_accept_handler() const; + + /** + * Use this method in order to set a new incomming socket acceptance handler. + * It's best to call this method right after the constructor call of this class. + * @brief Set a new acceptance handler + * @param value The new handler to set + */ + void set_accept_handler(const accept_handler_type &value); private: void cb_ev(::ev::io &w, int events); -- GitLab