Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4024620
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:44:38+00:00 2026-05-20T10:44:38+00:00

I have two (+) systems on a local network running an AIR application that

  • 0

I have two (+) systems on a local network running an AIR application that need to send/receive updated positions and other events between each other. I’m currently using an AIR-based socket server one of the instances.

The AMF and strong typing works great. What doesn’t, however, is the syncing between clients.

In my example below, clientA is trying to send an AMF packet to clientB. The SOCKET_DATA events fire off as expected on the server, in sync with the mouse, however the data that clientB receives very quickly gets out of sync and events are lost.

It’s fine if an occasional event gets dropped, however I need to know the most recent SOCKET_DATA event has the latest data. Instead, it just contains increasingly older data.

I’ve posted a test build (with source) here:

http://dev.marcelray.com/send/SocketTest.zip

Any ideas or thoughts are greatly appreciated.

Thanks!

Code Snippets:

clientA writeObject: (on MOUSE_MOVE to test large number of events)

protected function stage_mouseMoveHandler ( pEvent : MouseEvent ) : void
{
    var lOutgoingPacket : DataPacket = new DataPacket( pEvent.stageX , pEvent.stageY );

    clientAStatusText.appendText( "Sending packet: " + lOutgoingPacket + "\n" );

    clientA.writeObject( lOutgoingPacket );
}

clientB SOCKET_DATA handler:

private function clientB_socketDataHandler ( pEvent : ProgressEvent ) : void
{
    var lIncomingPacket : DataPacket = DataPacket( clientB.readObject() );  

    clientBStatusText.appendText( "Received packet: " + lIncomingPacket + "\n" );
}

Server’s SOCKET_DATA handler:

private function server_socketDataHandler ( pEvent : ProgressEvent ) : void
{
    var lSourceClient : Socket = pEvent.target as Socket;

    var lIncomingObject : * = lSourceClient.readObject(); 

    // Send message to all connectedClients
    for each ( var iClient : Socket in connectedClients )
    {
        // Don't send to client who sent the original command
        if ( iClient == lSourceClient )
            continue;

        iClient.writeObject( lIncomingObject );
        iClient.flush();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:44:39+00:00Added an answer on May 20, 2026 at 10:44 am

    I don’t think this is a problem with sync. The packets should always be in the correct order.

    I’m pretty sure the problem is that you’re assuming each call to Socket.writeObject will be received as a single SOCKET_DATA event, which is not necessarily true. What you need to do is send the length of the actual data along with the data. For example:

    socket.writeUnsignedByte(lengthOfData);
    socket.writeObject(data);
    

    See this example for writing data:

    https://github.com/magicalhobo/Flash-CS5-mobile-proxy/blob/master/com/magicalhobo/mobile/proxy/ProxyData.as

    And socketDataHandler for reading data:
    https://github.com/magicalhobo/Flash-CS5-mobile-proxy/blob/master/com/magicalhobo/mobile/proxy/MobileClient.as

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two system calls GetSystemTime() and GetThreadTimes() that I need to calculate the
I have two applications written in Java that communicate with each other using XML
I have two Slackware Linux systems on which the POSIX semaphore sem_open() call fails
We have two tasks (T1 and T2) in our vxWorks embedded system that have
I have two identical tables and need to copy rows from table to another.
I have a two part problem that needs fixing. I'll try my best to
I have two master pages and a content page. On my local machine this
I have two databases I need to work with, one oracle on a remote
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have inherited a middle tier system with some multi-Threading issues. Two different threads,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.