简体   繁体   English

接收广播(或其他数据包)时,0.0.0.0地址是什么意思?

[英]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. 我有两个脚本,第一个发送广播,第二个正在接收UDP数据包。 It is working only when the receiving script has his IP address set (via bind) to 0.0.0.0 . 仅当接收脚本的IP地址(通过bind)设置为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? 为什么127.0.0.1 (或者恰好是192.168.0.xx )不起作用?

Thank you, RA 谢谢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. 可能您的计算机具有两个或两个以上具有不同IP的接口,因为您已经知道127.0.0.1 IP表示本地计算机,而192.168.0.xx是路由器通过DHCP发送给您或由您静态分配的本地IP。 0.0.0.0是一个特殊的地址,表示您计算机的每个IP地址

So if you bind some service listener in 0.0.0.0 all IPs will be affected. 因此,如果您将某些服务侦听器绑定到0.0.0.0中,则所有IP都会受到影响。

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. 例如,您需要为本地主机接收且仅接收流量,然后将服务器设置为127.0.0.1,现在还需要来自192.168.0.xx的流量,然后绑定此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. 但是,如果您需要通过所有IP的流量,则将0.0.0.0地址绑定。如果您的计算机上运行的两个或多个接口具有两个不同的IP,则服务器将在两个IP上进行监听。 Hope I answered your question! 希望我回答了你的问题! Bye! 再见!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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