java - 如何在java网络中广播

标签 java networking client broadcasting

这是我第一次用 java 编程网络。 我一直在寻找一种方法,以某种方式向整个网络中的所有节点发送广播。让他们知道我的存在。 我正在尝试制作多人网络游戏,我希望客户能够看到所有可用的游戏以选择加入哪个游戏。 我想知道如何从服务器广播以及如何让客户端收听。

请简单点,我是新手:)

提前致谢。

最佳答案

要广播数据包,将它们发送到给定子网的广播地址(子网的最后一个地址)。 IP 255.255.255.255zero network 的广播地址.

A special definition exists for the IP broadcast address 255.255.255.255. It is the broadcast address of the zero network or 0.0.0.0, which in Internet Protocol standards stands for this network, i.e. the local network. Transmission to this address is limited by definition, in that it is never forwarded by the routers connecting the local network to the Internet.

Broadcast address

因此,要广播到您当前的网络,请将数据包发送到 255.255.255.255

关于java - 如何在java网络中广播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6568446/

相关文章:

python - 服务器客户端通信 Python

java - 防止 FlowLayout 垂直居中

linux - 获取收到的UDP数据包的目的地址

c - socket read() 的字节偏移量 (linux)

java - 客户端在监听服务器时主动等待

sockets - julia 中的 tcp 客户端和 java 中的 tcp 服务器

java - 如何保持哈希表中元素的顺序

java - JFrame 大小不正确

java - 无法运行 jar 文件?

C# begin*() 方法与服务器的线程池