An example of how to use the Async::TcpClient class
#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->connect();
}
~MyClass(void)
{
delete con;
}
private:
void onConnected(void)
{
cout << "Connection established to " << con->remoteHost() << "...\n";
con->write("GET /\n", 6);
}
{
cout <<
"Disconnected from " << con->
remoteHost() <<
"...\n";
Application::app().quit();
}
{
char *str = static_cast<char *>(buf);
string html(str, str+count);
cout << html;
return count;
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}