[Interest] Simple UDP listener question
Thiago Macieira
thiago.macieira at intel.com
Mon Jun 23 18:10:04 CEST 2014
Em seg 23 jun 2014, às 13:03:03, Robert Wood escreveu:
> Folks,
>
> I've managed to get a simple program going that sends out a UDP packet
> to a broadcast address (an Artnet Poll packet) and my embedded software
> is receiving this and sending out a Poll reply. Wireshark confirms that
> my embedded device is sending out the correct response, however, my Qt
> program is not picking up any reply at all. I should say, this is the
> first time I've used Qt for networking and it's my first embedded
> netowrking project, so I may be missing some very basic point.
>
> I am doing this in MainWindow initialisation:
>
> udpSocSend = new QUdpSocket(this);
> udpSocRec = new QUdpSocket(this);
> udpSocSend->bind(QHostAddress("192.168.0.18"),6454);
> udpSocRec->bind(6454, QUdpSocket::ShareAddress);
Pass the ShareAddress to all instances. Setting it on the second after the
first has bound without the flag will probably result in EADDRINUSE.
> connect(udpSocRec, SIGNAL(readyRead()),this,
> SLOT(processPendingDatagrams()));
>
> void MainWindow::processPendingDatagrams()
> {
>
> while (udpSocRec->hasPendingDatagrams())
> {
> QByteArray datagram;
> datagram.resize(udpSocRec->pendingDatagramSize());
> udpSocRec->readDatagram(datagram.data(), datagram.size());
> ui->textEdit->setText(tr("Received datagram:
> \"%1\"").arg(datagram.data()));
>
> }
> }
>
> My udpSocSend is working to send data out (an Artnet Poll), my STM32
> (embedded micro) is sending packets back according to Wireshark, but
> processPendingDatagrams() flatly refuses to be called!
Probably because it failed to bind to the port. See above.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list