I have two scripts, first sends a broadcast, second is receiving UDP packets. It is working only when the receiving script has his IP address set (via bind) to 0.0.0.0. Why? This address should be something like "not existing address", so how can the script have it set like his own address? Why 127.0.0.1 (or exactly 192.168.0.xx) does not work?
Thank you, RA
Probably your machine has two or more interfaces with different IPs, as you already know the 127.0.0.1
IP means your local machine and the 192.168.0.xx
the local IP sent to you by the router via DHCP or assigned by you statically, the 0.0.0.0
is a special address that means every IP address of your machine.
So if you bind some service listener in 0.0.0.0 all IPs will be affected.
For example, you need to receive ONLY and JUST ONLY traffic for your localhost, then you set your server on 127.0.0.1, now you also need the traffic from 192.168.0.xx then you bind on this IP. But if you need that traffic goes through all the IPs you bind the 0.0.0.0
address.. if you have two or more interfaces running on your machine with two different IPs, the server will listen on both.