I have an XNA game using a basic lockstep update loop. The client sends all commands to the server, and updates only if it has received the next turn's commands from the server.
When does a turn end? When the Server says so (using the timer class, it sends out every 200ms a "Turn Done" to all clients. If a client hasn't received the turn done message from the Server then it does not update, it just waits until it gets that message from the Server.
So, this works fine, for about 20 seconds. After that, the game starts stuttering. I'm not hosting for other players, it's just my client and my server, all on the same machine.
The issue seems to be the XNA game loop itself. While the Server uses a System.Timers.Timer to keep track of... time, the game itself is using gameTime.ElapsedGameTime.TotalSeconds. And guess what, XNA.GameTime races ahead. The game reaches the end of the Turn before the Server does, so it ends up waiting for the Server to respond. And XNA.GameTime is consistently faster than the timer, so the delay just keeps getting bigger.
So, my question is: Which is the most accurate way to measure time and synchronize the game and Server in this context? Also, even if I do synchronize two processes on the same machine (seems feasible), Is it realistic to expect two different PCs to be synced? (And no, I don't mean that both have the same time at the very same instant, but that 200ms on one machine is exactly 200ms on another machine in real time, as otherwise one of them will sooner or later fall behind. If it.s the client that falls behind he will lag, and if it is the Server that falls behind then the Client will stutter while waiting for the Server to end the turn)
ps Thanks for any ideas/insight.
pps Thanks but I am well aware of the 1500 archers article. Either it doesn't contain info helpful to this question or I am too dim to see how it does, so some extra explanation is what I need.