Http/HttpServer server operation class.
More...
#include <sttnet_English.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) |
| | Constructor, which is enabled by default. Limit the maximum number of connections to an IP address to 20; The fastest connection speed per second for the same IP address is 6. More...
|
| |
| bool | setFunction (std::function< bool(const HttpRequestInformation &inf, HttpServerFDHandler &k)> fc) |
| | Set a callback function for responding after receiving and successfully parsing an Http/Https request Register a callback function. More...
|
| |
| | 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) |
| | Constructor, which is enabled by default. Limit the maximum number of connections to an IP address to 20; The fastest connection speed per second for the same IP address is 6. More...
|
| |
| bool | startListen (const int &port, const int &threads=8) |
| | Start the TCP server listening program. More...
|
| |
| bool | setTLS (const char *cert, const char *key, const char *passwd, const char *ca) |
| | Enable TLS encryption and configure server-side certificate and key. More...
|
| |
| void | redrawTLS () |
| | Revoke TLS encryption, CA certificate, etc. More...
|
| |
| bool | setFunction (std::function< bool(TcpFDHandler &k, TcpFDInf &inf)> fc) |
| | Set the callback function after receiving a message from the client Register a callback function. More...
|
| |
| bool | stopListen () |
| | Stop listening. More...
|
| |
| bool | close () |
| | Close listening and all connected sockets. More...
|
| |
| bool | close (const int &fd) |
| | Close the connection of a specific socket. More...
|
| |
| bool | isListen () |
| | Return the listening status of the object. More...
|
| |
| SSL * | getSSL (const int &fd) |
| | Query the connection with the server, pass in the socket, and return the encrypted SSL handle. More...
|
| |
| | ~TcpServer () |
| | Destructor of TcpServer class. More...
|
| |
Http/HttpServer server operation class.
- Note
- support 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 |
Constructor, which is enabled by default. Limit the maximum number of connections to an IP address to 20; The fastest connection speed per second for the same IP address is 6.
- Note
- Turning on the security module has a performance impact
- Parameters
-
| maxFD | service object can accept the maximum number of connections |
| security_open | true: enable the security module false: disable the security module (enabled by default) |
| connectionNumLimit | The maximum number of connections from the same IP address |
| connectionRateLimit | The maximum number of connections per second to the same IP address |
| buffer_size | The maximum amount of data allowed to be transferred over the same connection (in KB) is 8KB by default |
| requestRatte | The maximum number of requests allowed in one second for the same connection (the default is 12 times) |
| checkFrequency | The frequency of checking zombie connections (in minutes) The default is 1 minute -1 means no check |
| connectionTimeout | The number of seconds that a connection is considered a zombie connection if there is no response (in seconds) The default is 60 seconds -1 means no limit |
Set a callback function for responding after receiving and successfully parsing an Http/Https request Register a callback function.
- Parameters
-
| fc | A function or function object for the callback function to respond after receiving and successfully parsing an Http/Https request
|
- Note
- The passed function should have the signature bool func(const HttpRequestInformation &inf, HttpServerFDHandler &k)
-
If processing fails, the connection will be closed
The documentation for this class was generated from the following file: