#include <iostream>
#include <cassert>
using namespace std;
class MyClass : public sigc::trackable
{
public:
MyClass(void)
{
server->clientConnected.connect(
mem_fun(*this, &MyClass::onClientConnected));
server->clientDisconnected.connect(
mem_fun(*this, &MyClass::onClientDisconnected));
cout << "Start AsyncFramedTcpClient_demo in another window to transfer "
"some frames to the server" << endl;
}
~MyClass(void)
{
delete server;
}
private:
{
con->
frameReceived.connect(mem_fun(*
this, &MyClass::onFrameReceived));
}
{
}
{
cout << "Received a frame with " << buf.size() << " bytes of data\n";
if (buf.size() == 4)
{
std::string cmd(buf.begin(), buf.end());
cout << "Quitting!\n";
Application::app().quit();
}
else
{
uint8_t next = 0;
for (size_t i=0; i<buf.size(); ++i)
{
assert(buf[i] == next++);
}
}
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}
The core class for writing asyncronous cpp applications.
A TCP connection with framed instead of streamed content.
A class for creating a TCP server.
An application class for writing non GUI applications.
void exec(void)
Execute the application main loop.
A TCP connection with framed instead of streamed content.
sigc::signal< void, FramedTcpConnection *, std::vector< uint8_t > & > frameReceived
A signal that is emitted when a frame has been received on the connection.
std::string toString(void) const
Return the string representation of the IP address.
const IpAddress & remoteHost(void) const
Return the IP-address of the remote host.
uint16_t remotePort(void) const
Return the remote port used.
DisconnectReason
Reason code for disconnects.
int numberOfClients(void)
Get the number of clients that is connected to the server.
A class for creating a TCP server.
Namespace for the asynchronous programming classes.