Recursive socket?

I’m having a strange problem with a socket I am using.

I write a message to the socket and then immediately receive a ProgressEvent.SOCKET_DATA event that reads that data that I just sent back off the socket.

So I send “AB123” to my socket and get an event that tells me “AB123” was just received over the socket.

The code has also successfully read data coming from another source. So I am pretty sure it is working. So is repeating back the message sent normal behaviour?

(A side problem is that I have to write to the socket exactly 3 times before the messages is received at the other end. Related?)

my write code:

function writeData(e:KeyboardEvent):void {
    trace("got a keyboard event, going to write now.");
    try {
        StampSocket.writeMultiByte("AB123", "US-ASCII");
        StampSocket.flush();
    } catch (e:IOError) {
        trace(e);
    }
}

and my read code


StampSocket.addEventListener(ProgressEvent.SOCKET_DATA, onSocketData);

function onSocketData(e:ProgressEvent):void {
    dataIn = (StampSocket.readUTFBytes(StampSocket.bytesAvailable));
    trace("and the data is: " +dataIn);
}

Any thoughts would be greatly appreciated.