Async 1.8.0
|
A class for creating a TCP server. More...
#include <AsyncTcpServer.h>
Public Member Functions | |
TcpServer (const std::string &port_str, const Async::IpAddress &bind_ip=IpAddress()) | |
Default constuctor. | |
virtual | ~TcpServer (void) |
Destructor. | |
ConT * | getClient (unsigned int index) |
Get the client object pointer from the server. | |
![]() | |
TcpServerBase (const std::string &port_str, const Async::IpAddress &bind_ip) | |
Default constuctor. | |
virtual | ~TcpServerBase (void) |
Destructor. | |
int | numberOfClients (void) |
Get the number of clients that is connected to the server. | |
TcpConnection * | getClient (unsigned int index) |
Get the client object pointer from the server. | |
int | writeAll (const void *buf, int count) |
Write data to all connected clients. | |
int | writeOnly (TcpConnection *con, const void *buf, int count) |
Send data only to the given client. | |
int | writeExcept (TcpConnection *con, const void *buf, int count) |
Send data to all connected clients except the given client. | |
void | setSslContext (SslContext &ctx) |
Set the SSL context for all new connections. | |
void | setConnectionThrottling (unsigned bucket_max, float bucket_inc, int inc_interval_ms) |
Enable connection throttling. | |
Public Attributes | |
sigc::signal< void, ConT * > | clientConnected |
A signal that is emitted when a client connect to the server. | |
sigc::signal< void, ConT *, typename ConT::DisconnectReason > | clientDisconnected |
A signal that is emitted when a client disconnect from the server. | |
Protected Member Functions | |
virtual void | createConnection (int sock, const IpAddress &remote_addr, uint16_t remote_port) override |
virtual void | emitClientConnected (TcpConnection *con_base) override |
![]() | |
void | addConnection (TcpConnection *con) |
void | removeConnection (TcpConnection *con) |
A class for creating a TCP server.
This class is used to create a TCP server that listens to a TCP-port. To use it, just create an instance and specify the TCP-port to listen to. When a client connects, a new Async::TcpConnection object is created which is used to do the actual communication. An example of how to use it is shown below.
Definition at line 127 of file AsyncTcpServer.h.
|
inline |
Default constuctor.
port_str | A port number or service name to listen to |
bind_ip | The IP to bind the server to |
Definition at line 135 of file AsyncTcpServer.h.
|
inlinevirtual |
Destructor.
Definition at line 144 of file AsyncTcpServer.h.
|
inlineoverrideprotectedvirtual |
Implements Async::TcpServerBase.
Definition at line 172 of file AsyncTcpServer.h.
References Async::TcpServerBase::addConnection().
|
inlineoverrideprotectedvirtual |
Implements Async::TcpServerBase.
Definition at line 181 of file AsyncTcpServer.h.
References Async::TcpServer< ConT >::clientConnected.
|
inline |
Get the client object pointer from the server.
index | The wanted client by number 0 - numberOfClients()-1 |
Definition at line 151 of file AsyncTcpServer.h.
References Async::TcpServerBase::getClient().
sigc::signal<void, ConT*> Async::TcpServer< ConT >::clientConnected |
A signal that is emitted when a client connect to the server.
con | The connected TcpConnection object |
Definition at line 161 of file AsyncTcpServer.h.
Referenced by Async::TcpServer< ConT >::emitClientConnected().
sigc::signal<void, ConT*, typename ConT::DisconnectReason> Async::TcpServer< ConT >::clientDisconnected |
A signal that is emitted when a client disconnect from the server.
con | The disconnected TcpConnection object |
Definition at line 169 of file AsyncTcpServer.h.