Skip to content
Snippets Groups Projects
Commit d03c8264 authored by Leon Dietrich's avatar Leon Dietrich Committed by Benny Baumann
Browse files

add: Async server socket documentation

parent d815690a
No related branches found
No related tags found
1 merge request!1First unit tests
...@@ -9,6 +9,17 @@ ...@@ -9,6 +9,17 @@
namespace rmrf::net { 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> { class async_server_socket : public std::enable_shared_from_this<async_server_socket> {
public: public:
typedef std::shared_ptr<async_server_socket> self_ptr_type; typedef std::shared_ptr<async_server_socket> self_ptr_type;
...@@ -25,11 +36,37 @@ private: ...@@ -25,11 +36,37 @@ private:
::ev::io io; ::ev::io io;
public: 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); 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(); ~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: private:
void cb_ev(::ev::io &w, int events); void cb_ev(::ev::io &w, int events);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment