Synchronous vs Asynchronous networking

Started by
1 comment, last by hplus0603 9 years, 7 months ago

Recently I decided to make a simple multiplayer game just to get my feet wet in network programming. I am using python and the problem I have is with what type of networking library to use. My two options are probably python's own socketserver library and twisted. So my question is: is synchronous (socket - socketserver) or asynchronous(twisted) networking better suited for games?

Advertisement

Depends on the game.

Are you okay with waiting for the data to come across the wire? A game like chess or a hobby connect 4 clone, it doesn't really matter if the game is blocked for two seconds waiting for your opponent's data. There is not much for the client to do. Other turn-based games might also be just fine stalling for anything from milliseconds to minutes.

Interactive games, where players are constantly changing things, you really must have asynchronous systems. In these games, a slow network packet should not make the rest of your game stutter. Imagine playing an action game with the engine blocking for normal network delays and jitter, it would likely drive the players crazy.

Asynchronous adds a bit of complexity, but if your game is interactive and it needs it, then it needs it and you pay the extra costs.

Note that python support select to avoid blocking the main thread. Python also supports threading.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement