# AS3 Socket problem

**URL:** https://forum.kirupa.com/t/as3-socket-problem/329864
**Category:** flash
**Created:** [October 27, 2012, 5:28pm UTC](https://forum.kirupa.com/t/as3-socket-problem/329864 "2012-10-27T17:28:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Tompa](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tompa](https://forum.kirupa.com/u/Tompa)
#### Post date: [October 27, 2012, 5:28pm UTC](https://forum.kirupa.com/t/as3-socket-problem/329864/1 "2012-10-27T17:28:34Z")

</div>

Hola!  
I’m writing a client in Flash using the AS3 Socket class.  
The problem is occuring when I’m sending packets too fast,  
here is a example:

![](http://forum.kirupa.com/uploads/kirupa/6640/9629e329e3156b45.jpg)

The first packet is as it should, but the second packet is sending the data twice!  
Here is the code I’m using to send packets:

```auto

public function login(id:String, pw:String):void {    
        if (socket.connected) {
                socket.writeUTFBytes(String(headerLogin) + String(int(id.length)) + id + String(int(pw.length)) + pw);
                socket.flush();
        }else {
                 trace("[Socket] Can't send data because you are not connected!");
        }
}

```

This is the only place where **socket.writeUTFBytes** is used, so there is no mistake with a forgotten function or so.

If you have any clue why it’s writing the data twice, don’t hesitate to post :cool:  
_Thanks in advance,  
~Tompa_
