# Recursive socket?

**URL:** <https://forum.kirupa.com/t/recursive-socket/313299>\
**Category:** Uncategorized\
**Created:** [August 25, 2010, 3:12pm UTC](https://forum.kirupa.com/t/recursive-socket/313299 "2010-08-25T15:12:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chilibean](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@chilibean](https://forum.kirupa.com/u/chilibean)\
**Post date:** [August 25, 2010, 3:12pm UTC](https://forum.kirupa.com/t/recursive-socket/313299/1 "2010-08-25T15:12:44Z")

</div>

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:

```auto
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

```auto

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.
