Skip to content

Instantly share code, notes, and snippets.

@iamazeem
Created February 16, 2017 11:44
Show Gist options
  • Save iamazeem/4aac4f9b626f93bd1e3e4b38e1468cfb to your computer and use it in GitHub Desktop.
Save iamazeem/4aac4f9b626f93bd1e3e4b38e1468cfb to your computer and use it in GitHub Desktop.
#include <QObject>
#include <QCoreApplication>
#include <QUdpSocket>
#include <QTimer>
int main( int argc, char *argv[] )
{
QCoreApplication app( argc, argv );
QUdpSocket _s;
_s.bind( QHostAddress::LocalHost, 9000 );
QTimer t;
t.start( 500 );
QObject::connect( &t, &QTimer::timeout, [&_s]()
{
const QByteArray str { "Testing...\n" };
auto ret = _s.writeDatagram( str, QHostAddress::LocalHost,9000 );
qDebug() << str << "ret:" << ret;
});
return app.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment