Http/HttpServer 服务端操作类
更多...
#include <sttnet.h>
|
| | HttpServer (const int &maxFD=10000000, const bool &security_open=true, const int &connectionNumLimit=20, const int &connectionRateLimit=6, const int &buffer_size=8, const int &requestRate=12, const int &checkFrequency=1, const int &connectionTimeout=60) |
| | 构造函数,默认是启用安全模块。限制一个ip最大连接为20;同一个ip每秒最快连接速度为6 更多...
|
| |
| bool | setFunction (std::function< bool(const HttpRequestInformation &inf, HttpServerFDHandler &k)> fc) |
| | 设置一个收到Http/Https请求并成功解析后进行响应的回调函数 注册一个回调函数 更多...
|
| |
| | TcpServer (const int &maxFD=10000, const bool &security_open=true, const int &connectionNumLimit=20, const int &connectionRateLimit=6, const int &buffer_size=8, const int &requestRate=12, const int &checkFrequency=1, const int &connectionTimeout=1800) |
| | 构造函数,默认是启用安全模块。限制一个ip最大连接为20;同一个ip每秒最快连接速度为6 更多...
|
| |
| bool | startListen (const int &port, const int &threads=8) |
| | 打开Tcp服务器监听程序 更多...
|
| |
| bool | setTLS (const char *cert, const char *key, const char *passwd, const char *ca) |
| | 启用 TLS 加密并配置服务器端证书与密钥 更多...
|
| |
| void | redrawTLS () |
| | 撤销TLS加密,ca证书等 更多...
|
| |
| bool | setFunction (std::function< bool(TcpFDHandler &k, TcpFDInf &inf)> fc) |
| | 设置收到客户端消息后的回调函数 注册一个回调函数 更多...
|
| |
| bool | stopListen () |
| | 停止监听 更多...
|
| |
| bool | close () |
| | 关闭监听和所有已连接的套接字 更多...
|
| |
| bool | close (const int &fd) |
| | 关闭某个套接字的连接 更多...
|
| |
| bool | isListen () |
| | 返回对象的监听状态 更多...
|
| |
| SSL * | getSSL (const int &fd) |
| | 查询和服务端的连接,传入套接字,返回加密的SSL句柄 更多...
|
| |
| | ~TcpServer () |
| | TcpServer 类的析构函数 更多...
|
| |
Http/HttpServer 服务端操作类
- 注解
- 支持http/1.0 1.1
| stt::network::HttpServer::HttpServer |
( |
const int & |
maxFD = 10000000, |
|
|
const bool & |
security_open = true, |
|
|
const int & |
connectionNumLimit = 20, |
|
|
const int & |
connectionRateLimit = 6, |
|
|
const int & |
buffer_size = 8, |
|
|
const int & |
requestRate = 12, |
|
|
const int & |
checkFrequency = 1, |
|
|
const int & |
connectionTimeout = 60 |
|
) |
| |
|
inline |
构造函数,默认是启用安全模块。限制一个ip最大连接为20;同一个ip每秒最快连接速度为6
- 注解
- 打开安全模块会对性能有影响
- 参数
-
| maxFD | 服务对象的最大接受连接数 |
| security_open | true:开启安全模块 false:关闭安全模块 (默认为开启) |
| connectionNumLimit | 同一个ip连接数目的上限 |
| connectionRateLimit | 同一个ip每秒钟连接数目的上限 |
| buffer_size | 同一个连接允许传输的最大数据量(单位为kb) 默认为8kb |
| requestRatte | 同一个连接一秒内允许的最大请求数量 (默认为12次) |
| checkFrequency | 检查僵尸连接的频率(单位分钟) 默认为1分钟 -1为不做检查 |
| connectionTimeout | 连接多少秒内没有任何反应就视为僵尸连接 (单位为秒) 默认60秒 -1为无限制 |
设置一个收到Http/Https请求并成功解析后进行响应的回调函数 注册一个回调函数
- 参数
-
| fc | 一个函数或函数对象,用于当收到Http/Https请求并成功解析后进行响应的回调函数 -参数:HttpRequestInformation &inf - Http/Https请求的信息 HttpServerFDHandler &k - 服务端对象的引用 -返回: bool - 返回true成功成功,返回false处理失败 |
- 注解
- 传入的函数应该有如下签名 bool func(const HttpRequestInformation &inf,HttpServerFDHandler &k)
-
如果处理失败了 会关闭连接
该类的文档由以下文件生成: