Tutorial :C# Game Network Library



Question:

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.

{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}

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#):

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:

http://code.google.com/p/raknetdotnet/

This might be what I'm looking for...


Solution:1

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).


Solution:2

Microsoft's own .NET based XNA allows you to create networked games on Windows and XBox 360.


Solution:3

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.


Solution:4

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 not have to have a gold membership :-)

http://www.engadget.com/2008/07/22/games-for-windows-live-now-free/


Solution:5

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.

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.

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.


Solution:6

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.


Solution:7

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.


Solution:8

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »