Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For my multiplayer game server, I made a class inheriting from "Microsoft.Xna.Framework.Game", just like I did for the client-side part.

The thing is, I don't need any graphical display for the server, so I end up with a useless blank game window floating around. Also, the LoadContent/UnloadContent and Draw overrides are left empty. On the other hand, I still need to use Microsoft.Xna.Framework.Game for the game loop and logic update parts.

So is there any special class in XNA made especially for the server-side part, or is everyone else doing it just like I do?

share|improve this question
up vote 3 down vote accepted

There is no class that is part of the XNA library that acts as a game server.

You probably should not use the framework to write the server code unless you are creating a peer to peer Xbox based game over Xbox Live. I assume that you are not doing so because you would then need to render things onto the screen.

All C# programs start in the public static void Main method, including a program begun with the XNA framework.

If you do not already know how to create a program and import the XNA libraries without using the framework, you may be in over your head when it comes to the creation of a multiplayer game.

share|improve this answer

An XNA application is a .NET application, just like any other. In your Program.cs on the server, don't call the constructor or Run() for the Game class; just run your server logic instead.

share|improve this answer
But if I do that, I won't have the game loop that the Game class provides. So I won't be able to update the game state at a fixed interval of time. – asmo Jun 5 '11 at 21:59
You could use the System.Thread.Sleep(time) to update something at a fixed interval of time, and create your own server-side game loop manually – IDWMaster Jun 5 '11 at 22:02
On a server why would you want a 60-times-per-second loop anyway? Wouldn't you rather have the control to make the server run faster or slower? – doppelgreener Jun 6 '11 at 1:44

What kind of multiplayer server you are going to write? Is this just a lobby server for setting up peer-to-peer games? Is this a full on multiplayer server that is dedicated to hosting the game and communicating with clients (like Counterstrike servers, for example)? Or are you wanting to add multiplayer capability to your game in which a player starts a game that others can join?

If the last variant is what you want, XNA/.NET do provide some networking classes.

If you want to create a dedicated multiplayer server, you should do as HydroxicAcid says and avoid using the entire XNA framework as you will not need much of what it provides. What you should do is isolate your logic from your rendering code (in separate assemblies!) so that you can reuse these classes in your server application. You'll want to look into serialization over a network of figure out some lightweight message format for transporting gameplay data. There may be some instances where a 1:1 match between how a game object is represented on the server must be very different from how that same object is represented on the client, so be prepared to deal with that.

If you want to create a lobby server, you probably don't need to even write it in C# or use the .NET framework or even run it on a Microsoft platform. Its sole purpose is to find other people that want to play the game and tell them about each other, so there will likely be no need to reuse any existing game code for that.

Whatever it is you're looking to do, you can find a lot of good resources on AppHub =>

share|improve this answer
That's brilliant. The separating logic idea. – AgentFire Mar 24 '12 at 6:28

Why is it a problem that your game doesn't draw anything?

It seems like you're tilting at windmills.

If you want you can make a console application and then just import the XNA networking classes that you actually need, or make any other type of application, and import the XNA networking stuff. If you need a fixed time update loop, that is pretty trivial to implement.

You can create a windows forms application, and use it with XNA, by following the information here:

You probably want your server to draw something though, like the current status, or provide some sort of GUI controls.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.