How do you structure game servers?

I can use winsock2 to send images and such over the internet, but I don't know how you structure a game server.

Like I can send resources to the client, but how would I update the game and such. How would I identify which package is which?
Last edited on
Disclaimer: What I'm about to tell you is merely theory I've read

1. Thinking of a 2d game or 3d game?
2. How many players does this server intend to serve?

I've come across a bit on 3d MMO's, and there's some surprising things about how they're structured.

I. MMO's try to keep the amount of data that needs passed from c-s and s-c minimal. Not only can this reduce costs for them, but it reduces the minimum internet speed to play, as many Americans (myself included) have sub-par internet.
So, MMO's do A LOT of planning and make use of various algorithms. I.e path prediction algorithm, the server will try to predict where a player will move to a bit before they actually do. This is supposed to keep things smooth for example on WoW when you're travelling in a group.

II. MMO's I'm pretty sure NEVER pass resources, i.e models and textures, to the client during run-time. The client will be installed with all such needed resources. If the server has an update, it will bar clients from playing until they get the update.

III. The networking part, i.e what parts can be UDP, and what packets need more safe means of travel, I can't tell you much. There is no small amount of work as far as networking goes. I'd imagine though for example, if the MMO has built in voice chat, it would be UDP. However if the client buys something from another client or NPC, you would want no risk of that not getting by. I'd imagine a lot of the server takes extra-safety.

If you just want a server that's intended for say, a 2-16 setup, there's still similar rules, but not as bad.

I. Valid question is where the server will be. Dota 2 has their own servers. Some games will have the server run on whoever is hosting the lobby however. Some games plan ahead and work with someone like GameRanger.

II. Like an MMO, genre and architecture matters. Is it an RTS. If so, is it a tile based engine? Does it if have layers? I'm not really sure on how RTS would handle communicating these things. In short, figure out exactly what you are doing/plan doing and do research.

III. What are limits of your networking? Some games actually don't support (or at-least don't handle well) playing internationally.

P.S - I'd suggest for networking games you use Raknet.
2D game, I expect less than 40 players. (Usually around 12-25). It's a tile based, chat game.

Not planning on an MMO at all.

So you're saying UDP.

I have a basic idea on how I want the server. I don't know how I can let the client know what I'm sending to it.

Like I don't want the client to thing the X & Y coordinates are the player attributes.
Ok, well I didn't think you'd make an MMO, (considering they take massive budgets and large highly experienced teams) just thought you might be curious.

I'm saying use UDP when you can. Nobody cares if there are blips here and there in voice chat. There are several parts you can't take that kind of risk though.

Just a tip, if you're not that familiar with networking protocols do a bit of a reading on them. There's a lot, but I can only imagine some of them being applicable to games.

What you're worried about though is getting data mixed up? I'd go learn Raknet, I'm pretty sure your problem would fix itself doing so.
No, I mean recognizing which data type is which. Not worried about sending data itself, just trying to figure out how to let the client know if it's a tree update, or a player update.

So it can work with the game loop.
Topic archived. No new replies allowed.