#include <iostream>
using namespace std;
class MyClass : public sigc::trackable
{
public:
MyClass(void)
{
con->
connected.connect(mem_fun(*
this, &MyClass::onConnected));
con->disconnected.connect(mem_fun(*this, &MyClass::onDisconnected));
con->dataReceived.connect(mem_fun(*this, &MyClass::onDataReceived));
con->setService("svxreflector", "tcp", "test.svxlink.org");
con->addStaticSRVRecord(3600, 1, 100, 5304, "localhost.");
con->connect();
}
~MyClass(void)
{
delete con;
}
private:
void onConnected(void)
{
std::cout <<
"Connection established to " << con->
remoteHost()
<<
":" << con->
remotePort() <<
"..." << std::endl;
}
{
std::cout <<
"Disconnected from " << con->
remoteHost()
<< "..." << std::endl;
}
{
char *str = static_cast<char *>(buf);
string html(str, str+count);
cout << html;
std::cout << "### Quitting: count=" << count << std::endl;
Application::app().quit();
return count;
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}
The core class for writing asyncronous cpp applications.
A_brief_description_for_this_file.
An application class for writing non GUI applications.
void exec(void)
Execute the application main loop.
A class for representing an IP address in an OS independent way.
sigc::signal< void > connected
A signal that is emitted when a connection has been established.
A class for handling exiting TCP connections.
static const char * disconnectReasonStr(DisconnectReason reason)
Translate disconnect reason to a string.
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.
A_brief_class_description.
Namespace for the asynchronous programming classes.