I would like to have a single DatagramSocket to listen for both unicast and broadcast messages. Is this possible?
A:
I think if you set the address to 0.0.0.0, it'll do the work.
Mehrdad Afshari
2008-12-05 20:49:20
+4
A:
Broadcasting is, by definition, a transmission function.
If your UDP socket is listening on a particular port and bound to INADDR_ANY
(aka 0.0.0.0) then it'll receive all packets sent to that port, regardless of whether they were sent to the local machine's specific IP addresses (i.e. unicast), or to the local subnet's broadcast address.
Alnitak
2008-12-06 12:51:18