So I'm trying to make a Flash game with TCP connection with an AIR server, and though I got it to work, I can't seem to send multiple messages at once...

Here's an example from the client's code:

Code:
if (keys[p1_jump_key])
        {
            p1_up = "down";
            sock.writeUTF("p1_up_down");
            sock.flush();
        }
        else
        {
            p1_up = "up";
            sock.writeUTF("p1_up_up");
            sock.flush();
        }
        if (keys[p1_crouch_key])
        {
            p1_down = "down";
            sock.writeUTF("p1_down_down");
            sock.flush();
        }
        else
        {
            p1_down = "up";
            sock.writeUTF("p1_down_up");
            sock.flush();
        }
And here's the server:

Code:
function socketDataHandler(event:ProgressEvent):void{
var socket:Socket = event.target as Socket;
var message:String = socket.readUTF();
for each (var socket:Socket in clientSockets)
{
        socket.writeUTF(message);
        socket.flush();
}
}
And here's how the client receives the message...

Code:
if(msg=="p1_down_down"){
        p1_down="down";
    }
    if(msg=="p1_down_up"){
        p1_down="up";
    }
    if(msg=="p1_up_down"){
        p1_down="down";
    }
    if(msg=="p1_up_up"){
        p1_down="up";
    }
So basically, when a key on the keyboard is pressed, it sends a message over to the server. The server is then supposed to send that message back to both clients and then it takes affect on the characters in the game. I can't seem to read multiple messages at once, though. When the down key is up, it sends the message "p1_down_up". When the up key is up, it sends the message "p1_up_up". Both messages are sending at once when neither of them are being pressed. The receiving client is, I suppose, just getting one of the signals, or perhaps neither of them. How do I make MULTIPLE signals get wrote and read over the server? I tried using an array but you can't write those apparently. Please help, I've been looking up answers for this allover the place for a week and asked on multiple forums but no one helped. Thank you.