|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
TCP服务器类 更多...
#include <tcp_server.hpp>
Public 成员函数 | |
| tcp_server_base (ports port, size_t worker_count=thread_pool::max_thread_threshhold()) | |
| 构造函数 | |
| Public 成员函数 继承自 tcp_server_base | |
| tcp_server_base (ports port, size_t worker_count=thread_pool::max_thread_threshhold()) | |
| 构造函数 | |
| virtual | ~tcp_server_base () |
| 析构函数 | |
| bool | set_client_handler (client_handler_t handler) |
| 设置客户端处理器 | |
| bool | set_exception_handler (exception_handler_t handler) |
| 设置异常处理器 | |
| virtual bool | start (int backlog=SOMAXCONN) noexcept |
| 启动服务器 | |
| void | stop () |
| 停止服务器 | |
| NEFORCE_NODISCARD bool | is_running () const noexcept |
| 检查服务器是否运行中 | |
| NEFORCE_NODISCARD ports | port () const noexcept |
| 获取监听端口 | |
额外继承的成员函数 | |
| Public 类型 继承自 tcp_server_base | |
| using | client_handler_t = function<void(tcp_socket)> |
| 客户端处理器类型 | |
| using | exception_handler_t = function<void(const exception&)> |
| 异常处理器类型 | |
| Protected 成员函数 继承自 tcp_server_base | |
| void | accept_loop () |
| 接受连接的主循环 | |
| virtual void | handle_client (tcp_socket client) |
| 处理单个客户端连接 | |
| Protected 属性 继承自 tcp_server_base | |
| unique_ptr< tcp_acceptor > | acceptor_ |
| TCP接受器 | |
| ports | port_ |
| 监听端口 | |
| atomic< bool > | running_ {false} |
| 运行标志 | |
| vector< thread > | worker_threads_ |
| 工作线程列表 | |
| thread_pool | client_pool_ |
| 客户端处理线程池 | |
| client_handler_t | client_handler_ |
| 客户端处理器 | |
| exception_handler_t | exception_handler_ |
| 异常处理器 | |
TCP服务器类
实现普通TCP服务器,使用tcp_acceptor接受连接。
主要功能:
在文件 tcp_server.hpp 第 169 行定义.
|
explicit |