C# 游戏网络库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# Game Network Library
提问by JohnV
I am developing an online strategy game using .Net v2. Although the game is primarily strategic, it does have some tactical elements that require reasonable network performance. I plan to use TCP packets for strategic data and UDP packets for tactical data.
我正在使用 .Net v2 开发在线策略游戏。虽然游戏主要是战略性的,但它确实有一些需要合理网络性能的战术元素。我计划将 TCP 数据包用于战略数据,将 UDP 数据包用于战术数据。
{EDIT} I forgot to mention that I am leaning away from WCF and .NET 3+ for a couple of reasons. First, because I want to keep my download small and most of my customers already have .NET 2.0. Second, because I would like to have the option of porting to Mac and Linux and am unsure of WCF availability in Mono. {/EDIT}
{EDIT} 我忘了提及,出于几个原因,我正在远离 WCF 和 .NET 3+。首先,因为我想保持我的下载量很小,而且我的大多数客户已经拥有 .NET 2.0。其次,因为我希望可以选择移植到 Mac 和 Linux,并且不确定 Mono 中的 WCF 可用性。{/编辑}
I am looking for network library recommendations. I have found a few options, such as GarageGames' Torque Network Library (C++), RakNet (C++), and the lidgren network library (C#):
我正在寻找网络库推荐。我找到了一些选项,例如 GarageGames 的 Torque Network Library (C++)、RakNet (C++) 和 Lidgren 网络库 (C#):
http://www.opentnl.org/http://www.jenkinssoftware.com/http://code.google.com/p/lidgren-network/
http://www.opentnl.org/ http://www.jenkinssoftware.com/ http://code.google.com/p/lidgren-network/
Does anyone have real-world experience with these or other libraries?
有没有人对这些或其他图书馆有实际经验?
I just stumbled on RakNetDotNet:
我偶然发现了 RakNetDotNet:
http://code.google.com/p/raknetdotnet/
http://code.google.com/p/raknetdotnet/
This mightbe what I'm looking for...
这可能就是我要找的...
采纳答案by Simon Gillbee
Why limit yourself to .NET 2.0. .NET 3.0 (or 3.5) contains WCF and is a solid, performant communications subsystem with good security. .NET 3.0 is just .NET 2.0 with additional libraries (WCF, WF, WPF).
为什么要限制自己使用 .NET 2.0。.NET 3.0(或 3.5)包含 WCF,是一个可靠、高性能的通信子系统,具有良好的安全性。.NET 3.0 只是带有附加库(WCF、WF、WPF)的 .NET 2.0。
回答by Mark Cidade
回答by Joel Martinez
I'd also like to note that "Games for Windows", which XNA uses on windows with its Live! networking APIs is now free ... which means that if you write an XNA game that uses the networking features, your users do nothave to have a gold membership :-)
我还想指出“Windows 游戏”,XNA 在 Windows 上使用它的 Live! 网络 API 现在是免费的...这意味着如果您编写使用网络功能的 XNA 游戏,您的用户不必拥有黄金会员资格:-)
http://www.engadget.com/2008/07/22/games-for-windows-live-now-free/
http://www.engadget.com/2008/07/22/games-for-windows-live-now-free/
回答by DesertShadow
If you're new to game development, I'd recommend XNA- it's easy to program with. The advantage of Torque, however, is it has asset creation tools, which can also be invaluable. For a higher end game or FPS, the Source engine is great.
如果您是游戏开发的新手,我会推荐 XNA——它很容易编程。然而,Torque 的优势在于它具有资产创建工具,这些工具也非常宝贵。对于高端游戏或 FPS,Source 引擎很棒。
回答by DesertShadow
You could take a look at Entanglar ( http://entanglar.dunnchurchill.com) if you are looking for something higher level. Entanglar provides full entity lifecycle and sync.
如果您正在寻找更高级别的东西,您可以查看 Entanglar ( http://entanglar.dunnchurchill.com)。Entanglar 提供完整的实体生命周期和同步。
回答by Tarnschaf
Although this question is rather old, a somewhat higher level system developed specifically for games is APlay- among the supported platforms is also C#. There are evaluation versions and it is free for personal use.
虽然这个问题很老,但专门为游戏开发的更高级别的系统是APlay- 在支持的平台中还有 C#。有评估版,可供个人免费使用。
You define your game objects in an UML alike fashion and an online code generator creates assemblies containing your game objects. Sending state updates is then as simple as calling setter methods.
您以类似 UML 的方式定义您的游戏对象,并且在线代码生成器创建包含您的游戏对象的程序集。发送状态更新就像调用 setter 方法一样简单。
Not the right thing, if you want to cope with sockets by yourself. Please also note that I am a developer of APlay so this is a biased answer.
如果你想自己处理套接字,这不是正确的事情。另请注意,我是 APlay 的开发人员,所以这是一个有偏见的答案。
回答by Dan
http://code.google.com/p/lidgren-network-gen3/
http://code.google.com/p/lidgren-network-gen3/
Lidgren.Network is a networking library for .net framework which uses a single udp socket to deliver a simple API for connecting a client to a server, reading and sending messages.
Lidgren.Network 是 .net 框架的网络库,它使用单个 udp 套接字提供简单的 API,用于将客户端连接到服务器、读取和发送消息。
回答by Watusimoto
An ancient question, but I'll put this out there for anyone else who stumbles across this. We're using OpenTNL for our game, Bitfighter, and I am consistently surprised at how well it works. And it's free if you can live with GPL.
一个古老的问题,但我会把它放在那里,供其他任何偶然发现的人使用。我们在我们的游戏 Bitfighter 中使用 OpenTNL,我一直对它的运行效果感到惊讶。如果您可以使用 GPL,则它是免费的。