# Is the XNA framework appropriate for server side programming?

I'm looking to create a text based MUD, so a lot of the elements of the XNA framework seem appropriate to what I need. Especially things like the general game loop, networking, etc. It looks like XNA is tightly coupled to an interactive environment with UI and audio, so I'm not sure if it's the right way to go.

Would it be easier to just recreate these types of aspects myself, attempt to bend the XNA framework to what I need, or is there a better framework for this type of work?

## 5 Answers

I don't think the XNA framework would offer you much of use for the server side of a text based game, no. You should look at the standard .NET framework class libraries for that use case.

But widening out the question a bit, although the XNA frameworks are really intended for clientside 2d and 3d game development, there might be cause to use parts of them on the server-side of a 2d or 3d game. It is common to re-use parts of the graphics engine on the server because the server has a need to do things like visibility and collision testing just as much as the client does. In that scenario, if your engine has used the math library from XNA, you'll need to link that in your server code too.

If you are using C#, you should just consider using WCF to abstract away the networking layer. A MUD wouldn't have a whole lot of network traffic, relatively speaking, so going this route could make things a lot easier for you. I've been using WCF for a turn-based strategy game, and it's worked out pretty well for me.

• Generally I'd agree, but WCF doesn't support straight telnet connections. For regular text-based MUDs, allowing users to telnet to the server is a given. – Agent_9191 Jul 17 '10 at 5:39
• @Agent_9191 Depending on your goals, it could make sense to have the telnet interface be a layer on top of a more robust API, e.g. one built on WCF. – Cody Brocious Jul 19 '10 at 14:20
• Wouldn't WCF introduce latency, or would you use a custom binding that talked raw sockets? – Nate Aug 20 '10 at 15:31
• Well, if he needs a telnet interface, WCF probably isn't a good choice anyway; I suspect it'd be overkill. But I wouldn't think latency would be an issue considering the information being sent back and forth would be relatively simple--certainly simpler than the payloads of many web services. I use WCF for a fairly complex turn-based strategy game, and I have not had any performance problems. I keep the payload small with custom serialization, and latency isn't an issue because messages aren't sent back and forth very often (for my project, most messaging happens at the end of each turn). – Mike Strobel Aug 20 '10 at 17:20

You can go the XNA route and just use the particular elements you desire (audio, networking, etc.); but, it's increasing the complexity of your project and decreasing your "immediate understanding" of the codebase.

Basically, as you add more middleware, your knowledge of the way your code is actually operating diminishes -- unless you delve into the middleware's implementation. As you distance yourself, you lose efficiency, ability, and understanding.

So, as stated above, it would be far more beneficial for you to use C# and the appropriate non-XNA libraries.

If you're doing this for your own edification, you might as well roll your own where you're interested in the area -- you'll learn more this way.

Go for it! Have fun!

It largely depends on your requirements.

If you are interested in supporting audio, friend invites, et cetera than I believe XNA is the way to go.

The major limitation you face with using XNA for networking is the player limit of 32 players per game.

When you develop a game with the XNA framework, it isn't absolutely necessary to be coupled to all the various APIs. Many people use the XNA framework but rely on other frameworks for networking.

My suggestion is to physically (write them down in notepad or something) list your needs and wants for the networking aspect. Then compare and contrast the various frameworks.

I lean towards saying "create from scratch", but that's just a gut feeling based on having worked with C# and MUD code separately. You'll have more control and learn more from rolling your own versions of whatever you might be able to use from XNA, anyway.

Any reason you're not using an existing MUD engine, at least for reference?

• Do a degree I am using an existing engine for reference. I'm attempting to port the SMAUG code base to C# from the existing C base. So the feature set is mostly defined, it's just getting it working in C#. – Agent_9191 Jul 14 '10 at 19:49