用于 Java 和 Objective-C 游戏的实时游戏网络库
我希望构建使用专用 Java 服务器和 iPhone 客户端以及 Java 桌面客户端构建的实时游戏。 Java 和 iPhone(特别是可靠的 UDP)有哪些可用的高性能网络传输库可用于实时多人游戏开发?
对于大多数基于实时动作的游戏(Counter-Strike、Left4Dead、Quake III)的一般建议是使用 UDP/IP 传输协议将消息作为“不可靠”数据包发送,以支持 TCP 的“保证”传送(因为存在问题)重发和延迟问题您无法轻松控制)。
- 半条命源引擎网络概述
- 雷神之锤 III 网络 另一个建议是构建一个可靠的 UDP 协议,让您“可选”保证 UDP 数据包的传送(但仍然无法保证 TCP 流等传送顺序,只要您的游戏可以处理乱序数据包)。
Project Darkstar 是一个带有 C++ 绑定的 Java MMO 服务器(对于轻量级实时网络库来说有点太重了)通用多人游戏)。
我见过用 C 语言编写的可靠 UDP 库: - Enet - 可靠的 UDP 库 - Cocoa AsyncSocket
I'm looking to build real-time games built using a dedicated Java server and iphone clients as well as Java desktop clients. What available high-performance network transport libraries that could be used for real-time multiplayer game development, exist for Java and iphone (specifically reliable UDP)?
The general advice for most real-time action based games (Counter-Strike, Left4Dead, Quake III) is to use UDP/IP transport protocol sending messages as "unreliable" packets in favor of the "guaranteed" delivery of TCP (because of issues with resend and latency issues you can't easily control).
- Half-Life Source Engine Networking Overview
- Quake III Networking
The other advice is to build a reliable UDP protocol that lets you "optionally" gurantee delivery of UDP packets (while still not being able to guarantee delivery order such as a TCP stream, as long as your game can handle out of order packets).
Project Darkstar is a Java MMO server with C++ bindings (a little to heavy for a light-weight real-time networking library for generic multiplayer games).
I've seen libraries written in C for reliable UDP:
- Enet - reliable UDP library
- Cocoa AsyncSocket
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 Kryo 及其关联的通信库 KryoNet。
它正是为这种应用程序(高性能网络传输)而设计的。我不确定是否有 Objective-C 绑定,但即使没有,也值得一看,看看框架的设计有多好。
Have a look at Kryo and its associated communication library KryoNet.
It's designed for exactly this kind of application (high performance network transport). I'm not sure if there is an Objective-C binding yet but even if there isn't it is well worth a look just to see how well the framework is designed.
既然你提到了UDP。这是一个 java 游戏服务器 库(咳咳...由我编写!),它提供UDP 和 TCP 都支持。可靠的UDP原来是TCP。您可以在 UDP 之上编写自己的自定义 ack 逻辑,但通常最好使用 TCP 来处理需要到达服务器的内容,而使用 UDP 来处理其他所有内容。
在jetserver中,同一个会话同时使用UDP和TCP进行通信。网络消息可以通过 交付保证,可靠 = TCP 和快速 = UDP。
Since you mentioned UDP. Here is a java game server library (ahem... written by me!) that provides both UDP and TCP support. Reliable UDP turns out to be TCP. You can write your own custom ack logic on top of UDP, but generally it is better to go with TCP for stuff that needs to reach server and UDP for everything else.
In jetserver, the same session uses both UDP and TCP to communicate. Network messages can be sent with delivery guaranty, Reliable = TCP and FAST = UDP.
“特别可靠的 UDP”
UDP 在设计上不可靠。这就像发送旧的(非电子邮件)邮件。您将信放入信封,写上地址,贴上邮票,然后将其投入邮箱。它可能会被转移,但你不能确定。
UDP 是为速度比正确性更重要的情况而设计的(正确性就像“我的应用程序需要正确地逐位传输所有内容)。
例如,像 Skype 视频聊天这样的应用程序需要更多的带宽和更少的延迟,一些丢失的位可以修复在应用程序级别(因此它使用 UDP)。与此同时,基于文本的聊天需要更少的带宽并且可以承受更大的延迟,但需要更高的正确性(您如何知道这个字符串:fsdfdsfsd 是否正确传输?用什么语言?等等) ),所以它需要 TCP,实际上这就是 Skype 中的工作原理。
"specifically reliable UDP"
UDP is not reliable by it's design. It's like sending old (not electronic) mail. You put your letter in the envelope, write the address, place the stamp, and you drop that to the mailbox. It might be transferred, but you can't be sure.
UDP is designed for situations where speed is more important than correctness (correctness as in "my app needs everything to be correctly transferred bits by bits).
For example, applications like skype videochat needs more bandwidth and less latency, some lost bits can be fixed at the application level (so it uses UDP). In the meantime, text-based chat needs less bandhwidth and survives much greater latencies, but needs more correctness (how do you know this string: fsdfdsfsd is transferred correctly? in what language? etc), so it needs TCP. And actually that's how stuff works in skype.