I once tried to write a simple game with UDP in a week as a throwaway test. It went horribly.

I threw it away early. The main problem i had was restoring the game state of all players/enemies/objects to an old state and fast forward the game to the point of time the player is playing (ie half a second before a jump. A little early or late can make the player miss the jump)

Maybe this method is not the easiest way? i suspect it to be but i designed it wrong from the beginning and realized at the end of 2nd day. (so i didnt learn too much or wasted that much time)

For myself and others, What is involved for a simple UDP game and how do i write one? Or how do i solve the prediction problem restoring to state properly.

I'll mark this as CW bc i know there will be lots of helpful answers.


4 Answers 4


Glenn Fiedler has written an excellent set of articles on this, which covers pretty much all of the basic concepts.

  • \$\begingroup\$ The Floating Point Determinism article blew my head. Its too bad Synchronizing State isnt done because thats the one i wanted to read. Although Floating Point Determinism does answer lots of questions. \$\endgroup\$
    – user1047
    Jul 26, 2010 at 11:15
  • \$\begingroup\$ None of those articles go in depth about state-synchronization, which is what he's asking \$\endgroup\$ Jun 28, 2011 at 22:40

Rolling your own can be educational, but you often get more done if you can leverage an existing implementation (or at least start from there).

I've used both ENet and Raknet. I only used Enet in a simple game but it did what I needed. Enet uses a lower level API than Raknet. Raknet was used in a larger project. Raknet is extremely powerful, but wants to make you structure your game around Raknet's framework.


  • Connection Management
  • Sequencing
  • Channels
  • Reliability
  • Fragmentation and Reassembly
  • Aggregation
  • Adaptability
  • Portability
  • Freedom


  • Object replication
  • Autopatcher
  • Secure connections
  • Robust communication layer (basically all of Enets features rolled up in one item)
  • Remote procedure calls
  • Voice communication
  • NAT punchthrough
  • \$\begingroup\$ +1 for ENet, I've been using it for a while now for clients and they like it. \$\endgroup\$ Jul 27, 2010 at 7:26
  • \$\begingroup\$ He is asking about state synchronization - this answer has nothing to do with that \$\endgroup\$ Jun 28, 2011 at 22:41
  • \$\begingroup\$ -1, same reason as BlueRaja \$\endgroup\$ Nov 24, 2011 at 18:43

If you have the time and energy, you could download the Quake 3 source and study it. It's fairly easy to comprehend if you're comfortable with C, and equally easy to tinker with.

Which other multiplayer games have source available and use UDP?


If you go homebrew (as I did) you're going to learn tons - also about stuff you didn't want to know. Like NAT traversal. According to caspin, Enet is missing out on that, but you could always find some open source STUN code that works in most situations.


You must log in to answer this question.