An example of how to use the Async::UdpSocket class
#include <iostream>
using namespace std;
using namespace Async;
class MyClass : public SigC::Object
{
public:
MyClass(void)
{
sock->dataReceived.connect(slot(*this, &MyClass::onDataReceived));
sock->write(addr, 12345, "Hello, UDP!\n", 13);
}
~MyClass(void)
{
delete sock;
}
private:
void onDataReceived(
const IpAddress& addr,
void *buf,
int count)
{
cout << "Data received from " << addr << ": " << static_cast<char *>(buf);
Application::app().quit();
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}