#include <AsyncUdpSocket.h>
#include <iostream> #include <AsyncCppApplication.h> #include <AsyncUdpSocket.h> #include <AsyncIpAddress.h> using namespace std; using namespace Async; class MyClass : public SigC::Object { public: MyClass(void) { sock = new UdpSocket(12345); sock->dataReceived.connect(slot(this, &MyClass::onDataReceived)); IpAddress addr("127.0.0.1"); sock->write(addr, 12345, "Hello, UDP!\n", 13); } ~MyClass(void) { delete sock; } private: UdpSocket * sock; 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) { CppApplication app; MyClass my_class; app.exec(); }
Definition at line 123 of file AsyncUdpSocket.h.
|
|
Constructor.
|
|
|
Destructor.
|
|
|
Check if the initialization was ok.
Definition at line 146 of file AsyncUdpSocket.h. |
|
||||||||||||||||||||
|
Write data to the remote host.
|
|
|
A signal that is emitted when data has been received.
Definition at line 165 of file AsyncUdpSocket.h. |
|
|
A signal that is emitted when the send buffer is full.
Definition at line 172 of file AsyncUdpSocket.h. |
1.4.4