Java可靠的UDP [英] Java reliable UDP

查看:667
本文介绍了Java可靠的UDP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请建议使用Java库,以实现可靠的udp。它将用于游戏服务器与客户端和其他服务器通信。



PS也许你可以建议使用这种任务(游戏服务器)更有效率的技术?

这是一个动作类型的游戏,所以它需要尽快与服务器通话。

/ p>

编辑2:我发现 Enet 它用于一个FPS游戏,但它的C ++,如果我多次调用它多次,会有开销。

解决方案

您可能会发现,对于所有邮件类型,您不需要可靠的邮件。例如,如果你重复发送玩家的状态,并且几个数据包丢失,它可能甚至无所谓。






有支持Java的可靠的高性能UDP库。其中之一是29West的LBM。这不是更便宜,因为很难得到这个权利。即使有专业的产品,你可能需要一个专用的网络UDP以尽量减少损失。



为了游戏的目的,我建议你使用JMS服务像ActiveMQ,运行在任何地方你可以运行Java。您应该可以每秒发送10K封邮件,延迟几毫秒。






当人们说某事必须是快速,这可能意味着什么。对于某些人来说,这意味着10ms,1ms,100us,10us,1us是可以接受的。一些网络路由器支持传递600 ns延迟的数据包。延迟越低,成本越高,对设计的影响也越大。假设你需要更多的速度超过你的需要可以不必要地影响设计和成本。



你必须要有现实感,因为你有一个人机界面。人类不能比大约1/20秒或大约50ms更快地响应。如果你保持信息少于5毫秒,人类将无法区分差异。


Please suggest java library, that implements reliable udp. It will be used for a game server to communicate to clients and to other servers.

PS Maybe you can suggest tech that will be more productive to work with for such task(game server)? But this must work on linux.

Edit: It's an action type game, so it needs to talk to server as fast as possible.

Edit 2: I found Enet which was used for a FPS game, but it's C++, will there be an overhead if I call it many times a second?

解决方案

You may find you don't need reliable messaging for all message types. For example, if you are repeatedly sending the status of things like players, and a few packets are lost it may not even matter.


There are reliable high performance UDP based libraries which support Java. One of these is 29West's LBM. It is not cheaper because it is very hard to get this right. Even with a professional product you may need a dedicated network for UDP to minimize loss.

For the purpose of a game I suggest you use a JMS service like ActiveMQ which runs wherever you can run Java. You should be able send 10K messages per second with a few milli-seconds latency.


When people say something must be as fast as possible, this can mean just about anything. For some people this means 10 ms, 1 ms, 100 us, 10 us, 1 us is acceptable. Some network routers support passing packets with a 600 ns latency. The lower the latency the greater the cost and the greater the impact on the design. Assuming you need more speed than you need can impact the design and cost unnecessarily.

You have to be realistic seeing that you have a human interface. A human cannot respond faster than about 1/20 of a second or about 50 ms. If you keep the messaging to less than 5 ms, a human will not be able to tell the difference.

这篇关于Java可靠的UDP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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