Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem which I can't understand.

To understand it I wrote a socket client on AS3 and a server on python/twisted, you can see the code of both applications below.

Let's launch two clients at the same time, arrange them so that you can see both windows and press connection button in both windows. Then press and hold any button.

What I'm expecting:

Client with pressed button sends a message "some data" to the server, then the server sends this message to all the clients(including the original sender) .

Then each client moves right the button 'connectButton' and prints a message to the log with time in the following format: "min:secs:milliseconds".

What is going wrong:

The motion is smooth in the client that sends the message, but in all other clients the motion is jerky.

This happens because messages to those clients arrive later than to the original sending client. And if we have three clients (let's name them A,B,C) and we send a message from A, the sending time log of B and C will be the same.

Why other clients recieve this messages later than the original sender?

By the way, on ubuntu 10.04/chrome all the motion is smooth. Two clients are launched in separated chromes.

windows screenshot

linux screenshot

Listing of log, four clients simultaneously:

[16:29:33.280858] >> some data
[16:29:33.280912] << some data
[16:29:33.280970] << some data
[16:29:33.281025] << some data
[16:29:33.281079] << some data
[16:29:33.323267] >> some data
[16:29:33.323326] << some data
[16:29:33.323386] << some data
[16:29:33.323440] << some data
[16:29:33.323493] << some data
[16:29:34.123435] >> some data
[16:29:34.123525] << some data
[16:29:34.123593] << some data
[16:29:34.123648] << some data
[16:29:34.123702] << some data

AS3 client code, I left only relevant part, full code here.

        private var socket           :XMLSocket;

        socket = new XMLSocket();
        socket.addEventListener(DataEvent.DATA, dataHandler);

        private function dataHandler(event:DataEvent):void
            var now:Date = new Date();
            textField.appendText( + "          time = " + now.getMinutes() + ":" + now.getSeconds() + ":" + now.getMilliseconds() + "\n");
            connectButton.x += 2;

        private function keyDownHandler(event:KeyboardEvent):void
            socket.send("some data");

        private function connectMouseDownHandler(event:MouseEvent):void
            var connectAddress:String = "";
            var connectPort:Number = 13250;

            Security.loadPolicyFile("xmlsocket://" + connectAddress + ":" + String(connectPort));
            socket.connect(connectAddress, connectPort);

Python server code.

share|improve this question

closed as off-topic by Byte56 Dec 13 '13 at 16:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Byte56
If this question can be reworded to fit the rules in the help center, please edit the question.

Too much code, you could try to post only the relevant part, and if you feel like posting it all only posting it as a link (one more +1 and you should have enough rep, I guess?). – o0'. Mar 19 '12 at 13:15
thanks guys, I left only relevant part of as3 code. – Rnd_d Mar 20 '12 at 8:34
one guy answered me right on stackoverflow – Rnd_d Apr 22 '12 at 9:13