|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
SSL/TLS服务器类 更多...
#include <tcp_server.hpp>
Public 成员函数 | |
| ssl_server (ports port, size_t worker_count=thread_pool::max_thread_threshhold()) | |
| 构造函数 | |
| bool | load_certificate (const string &cert_file, const string &key_file) |
| 加载证书和私钥 | |
| void | set_ssl_context (ssl_context ctx) |
| 设置SSL上下文 | |
| NEFORCE_NODISCARD ssl_context & | get_ssl_context () noexcept |
| 获取SSL上下文 | |
| NEFORCE_NODISCARD const ssl_context & | get_ssl_context () const noexcept |
| 获取常量SSL上下文 | |
| bool | start (int backlog=SOMAXCONN) noexcept override |
| 启动SSL服务器 | |
| 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) |
| 设置异常处理器 | |
| 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_ |
| 异常处理器 | |
SSL/TLS服务器类
实现SSL/TLS加密的TCP服务器,使用ssl_acceptor接受连接。
使用示例:
在文件 tcp_server.hpp 第 211 行定义.
|
inlinenoexcept |
|
inlinenoexcept |
加载证书和私钥
| cert_file | 证书文件路径 |
| key_file | 私钥文件路径 |
| void ssl_server::set_ssl_context | ( | ssl_context | ctx | ) |
|
overridevirtualnoexcept |