[Interest] Simple UDP listener question

Robert Wood robert.wood at apostrophe.co.uk
Wed Jul 2 15:39:58 CEST 2014


Just for the sake of preventing someone banging their head against a 
brick wall for ages in the future, this turned out to be the fact that 
some of the returning UDP packets were being picket up by the *sending* 
socket. If I only open one socket, both sending and receiving on it, the 
whole thing works a treat. Or, of course, if I have a second 
processPendingDatagrams type function that listens for incoming packets 
on the "sending" socket.

I suspect many people haven't come across this before because, I guess, 
normally, you don't send and receive on the same port. Artnet specifies 
you have to and so this issue raises its ugly head.

On 23/06/14 13:03, Robert Wood wrote:
> 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);
>       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!
>
> Wireshark shows this in terms of a reply:
>
> 2475	795.416268000	192.168.0.177	192.168.0.18	ARTNET	282	ArtPollReply
> (0x2100)
>
> The STM32 is at address 192.168.0.177, my [Linux] Qt machine is
> 192.168.0.18.
>
> The data in the datagram looks OK mto me on Wireshark.
>
> Can anyone see anything I am doing wrong please?
>
> Thanks!
>
> Rob
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



More information about the Interest mailing list