接收广播(或其他数据包)时 0.0.0.0 地址是什么意思? [英] What is the meaning of 0.0.0.0 address while receiving broadcast (or other packets)?

查看:42
本文介绍了接收广播(或其他数据包)时 0.0.0.0 地址是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个脚本,第一个是发送广播,第二个是接收UDP数据包.仅当接收脚本将其 IP 地址设置(通过绑定)为 0.0.0.0 时,它才起作用.为什么?这个地址应该类似于不存在的地址",那么脚本如何将其设置为他自己的地址?为什么 127.0.0.1(或完全是 192.168.0.xx)不起作用?

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?

谢谢你,RA

推荐答案

可能你的机器有两个或多个不同 IP 的接口,因为你已经知道 127.0.0.1 IP 意味着你的本地机器和192.168.0.xx 路由器通过DHCP发给你的或者你静态分配的本地IP,0.0.0.0是一个特殊的地址,表示您机器的每个 IP 地址.

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.

因此,如果您在 0.0.0.0 中绑定某个服务侦听器,则所有 IP 都会受到影响.

So if you bind some service listener in 0.0.0.0 all IPs will be affected.

例如,您需要仅接收本地主机的流量,然后将服务器设置为 127.0.0.1,现在您还需要来自 192.168.0.xx 的流量,然后您绑定到此 IP.但是,如果您需要流量通过您绑定 0.0.0.0 地址的所有 IP.如果您的机器上有两个或多个接口在使用两个不同的 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. 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!

这篇关于接收广播(或其他数据包)时 0.0.0.0 地址是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆