#include <tcp_server.hpp>
◆ TCPServer() [1/3]
TCPServer::TCPServer |
( |
size_t | maxConnections | ) |
|
|
explicit |
Construct a new TCPServer object.
- Parameters
-
maxConnections | The maximum number of clients the server can handle. Will be capped at HARD_CONNECTION_LIMIT. |
◆ TCPServer() [2/3]
◆ TCPServer() [3/3]
◆ ~TCPServer()
TCPServer::~TCPServer |
( |
| ) |
|
◆ operator=()
◆ setOnConnect()
void TCPServer::setOnConnect |
( |
std::function< void(std::shared_ptr< TCPSocket >)> const & | onConnect | ) |
|
Set the function to call when a new client connects.
- Parameters
-
onConnect | The function to call when a new client connects. |
◆ setOnData()
void TCPServer::setOnData |
( |
std::function< void(std::shared_ptr< TCPSocket >, std::string &)> const & | onData | ) |
|
Set the function to call when data is received from a client.
- Parameters
-
onData | The function to call when data is received from a client. |
◆ setOnDisconnect()
void TCPServer::setOnDisconnect |
( |
std::function< void(std::shared_ptr< TCPSocket >)> const & | onDisconnect | ) |
|
Set the function to call when a client disconnects.
- Parameters
-
onDisconnect | The function to call when a client disconnects. |
◆ start()
bool TCPServer::start |
( |
const std::string & | ip, |
|
|
uint16_t | port, |
|
|
int | listen_backlog = 1 ) |
Start the server.
- Parameters
-
ip | The IP address to listen on, or an empty string to listen on all interfaces. |
port | The port to listen on. |
listen_backlog | The maximum number of pending connections. |
- Returns
- true on success, false on failure.
◆ stop()
The documentation for this class was generated from the following files: