Network Configurations

One of the most important things to consider when writing a networked game is what type of network you'll be using (peer-to-peer, client/server, or a hybrid). The type of network you choose will have a big impact on how you handle your in-game network traffic, and on the performance of your application.

In a peer-to-peer network, all the participants are clients of each other. When something changes on one computer, that computer sends a message to all other computers telling them what's happened. In space shooter game terms, let's say you're playing a game with five participants. If one computer's player shoots a bullet, that computer sends a message to all other computers telling them that a bullet has been fired. A typical peer-to-peer architecture diagram is shown in Figure 17-3.

Typical peer-to-peer network—all computers interact with each other

Figure 17-3. Typical peer-to-peer network—all computers interact with each other

In contrast to a peer-to-peer network, a client/server network configuration typically has one server, and the rest of the machines are clients. All communication is run through the server. If you took the previous example of five people playing a space shooter game and one player firing a shot, in a client/server network that computer would send a message to the server (unless that computer is the server), and then the server would send the message out to all the clients.

A typical client/server configuration ...

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.