Game servers: UDP vs TCP by Christoffer Lernö, an article by Christoffer Lernö can be found at
http://1024monkeys.wordpress.com/2014/04/01/game-servers-udp-vs-tcp/Why UDP is “hard”
Topics:
- Background
- What TCP means in practice
- Why UDP is “hard”
- The flawed case for TCP
- When TCP doesn’t work
- Myth: Reliable UDP is TCP implemented poorly
- The bottom line:
So UDP or TCP?
Use HTTP/HTTPS over TCP if you are making occasional, client-initiated stateless queries and an occasional delay is ok.
Use persistent plain TCP sockets if both client and server independently send packets but an occasional delay is ok (e.g. Online Poker, many MMOs).
Use UDP if both client and server may independently send packets and occasional lag is not ok (e.g. Most multiplayer action games, some MMOs)
These are mixable too: Your MMO client might first use HTTP to get the latest updates, then connect to the game servers using UDP.
Never be afraid of using the best tool for a task.