简体   繁体   中英

What is the meaning of 0.0.0.0 address while receiving broadcast (or other packets)?

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 sended to you by the router via DHCP or assigned by you statically, the 0.0.0.0 is a special addres 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 trafic for your localhost, then you set your server on 127.0.0.1, now you also need the trafic from 192.168.0.xx then you bind on this IP. But if you need that trafic 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. Hope I answered your question! Bye!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM