An example of how to use the Async::UdpSocket class
#include <iostream>
using namespace std;
class MyClass : public sigc::trackable
{
public:
MyClass(void)
{
sock->dataReceived.connect(mem_fun(*this, &MyClass::onDataReceived));
sock->write(addr, 12345, "Hello, UDP!\n", 13);
}
~MyClass(void)
{
delete sock;
}
private:
void onDataReceived(
const IpAddress& addr, uint16_t port,
void *buf, int count)
{
cout << "Data received from " << addr << ":" << port << ": "
<< static_cast<char *>(buf);
Application::app().quit();
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}
The core class for writing asyncronous cpp applications.
Platform independent representation of an IP address.
Contains a class for using UDP sockets.
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.
A class for working with UDP sockets.
Namespace for the asynchronous programming classes.