Reputation: 4479
If I bind my udp socket like this:
connectState = socket->bind(QHostAddress::Any, 14550);
then my understanding is that all the device on my LAN with port 14550 will trigger the readyRead signal if it writes something out using UDP.
Am I correct? If some device is on prot 12345, then it won't trigger readyRead signal? And is it possible to bind to only a specific address range?
Upvotes: 0
Views: 416
Reputation: 1908
I'm not sure but I have the feeling you mix up AnyAddress with broadcast
then my understanding is that all the device on my LAN with port 14550 will trigger the readyRead signal if it writes something out using UDP.
No. It triggers a readyRead when it sends an UDP packet on any address of your server it can reach. The UDP package has to be addressed to your computer. In this case ::Any
means any interface even the virtual 127.0.0.1.
The UDP package has to be send to the selected port.
And is it possible to bind to only a specific address range?
As far as I know NO. In all OS I know of ::Any
translates to 0.0.0.0 which is a special address telling the OS to "listen on any available interface" If you want to exclude some you have to somehow determine the list of IPs your interested in and build a collection of QUdpSocket to listen to.
Upvotes: 1