如何在java网络中播放 [英] How to broadcast in java network

查看:162
本文介绍了如何在java网络中播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Its my first time programing network in java. I was looking for a way to send to somehow broadcast to all nodes in the whole networking. To let them know of my existence. I'm trying to make a multiplayer network game, and I want the clients to be able to see all the games available to choose which one to join. I want to know how to broadcast from the server and also how to make the clients listen.

请简单说明,我是一个新手:)

提前致谢。

推荐答案

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

To broadcast data packets, send them to the broadcast address of the given subnet (the last address of the subnet). The IP 255.255.255.255 is the broadcast address for the zero network.


IP广播地址255.255.255.255存在特殊定义。它是零网络的广播地址或0.0.0.0,其在因特网协议标准中代表该网络,即本地网络。传输到此地址的定义受到限制,因为它永远不会被连接本地网络到Internet的路由器转发。

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.

< a href =http://en.wikipedia.org/wiki/Broadcast_address =noreferrer>广播地址

所以要广播给你当前网络,将数据包发送到 255.255.255.255

So to broadcast to your current network, send the packets to 255.255.255.255.

这篇关于如何在java网络中播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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