Async
0.18.0
|
A class for creating a TCP server. More...
#include <AsyncTcpServer.h>
Public Member Functions | |
TcpServer (const std::string &port_str) | |
Default constuctor. | |
~TcpServer (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. | |
Public Attributes | |
SigC::Signal1< void, TcpConnection * > | clientConnected |
A signal that is emitted when a client connect to the server. | |
SigC::Signal2< void, TcpConnection *, TcpConnection::DisconnectReason > | clientDisconnected |
A signal that is emitted when a client disconnect from the server. | |
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 126 of file AsyncTcpServer.h.
Async::TcpServer::TcpServer | ( | const std::string & | port_str | ) |
Default constuctor.
port_str | A port number or service name to listen to |
Async::TcpServer::~TcpServer | ( | void | ) |
Destructor.
TcpConnection* Async::TcpServer::getClient | ( | unsigned int | index | ) |
Get the client object pointer from the server.
index | The wanted client by number 0 - numberOfClients()-1 |
int Async::TcpServer::numberOfClients | ( | void | ) |
Get the number of clients that is connected to the server.
int Async::TcpServer::writeAll | ( | const void * | buf, |
int | count | ||
) |
Write data to all connected clients.
buf | The data buffer |
count | The number of bytes in the data buffer |
int Async::TcpServer::writeExcept | ( | TcpConnection * | con, |
const void * | buf, | ||
int | count | ||
) |
Send data to all connected clients except the given client.
con | The TcpConnection object not to send to |
buf | The data buffer |
count | The number of bytes in the data buffer |
int Async::TcpServer::writeOnly | ( | TcpConnection * | con, |
const void * | buf, | ||
int | count | ||
) |
Send data only to the given client.
con | The TcpConnection object to send to |
buf | The data buffer |
count | The number of bytes in data buffer |
SigC::Signal1<void, TcpConnection *> Async::TcpServer::clientConnected |
A signal that is emitted when a client connect to the server.
con | The connected TcpConnection object |
Definition at line 183 of file AsyncTcpServer.h.
SigC::Signal2<void, TcpConnection *,TcpConnection::DisconnectReason> Async::TcpServer::clientDisconnected |
A signal that is emitted when a client disconnect from the server.
con | The disconnected TcpConnection object |
Definition at line 191 of file AsyncTcpServer.h.