# Socket

**URL:** <https://forum.kirupa.com/t/socket/307846>\
**Category:** flash\
**Created:** [April 12, 2010, 12:26am UTC](https://forum.kirupa.com/t/socket/307846 "2010-04-12T00:26:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![theBond](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@theBond](https://forum.kirupa.com/u/theBond)\
**Post date:** [April 12, 2010, 12:26am UTC](https://forum.kirupa.com/t/socket/307846/1 "2010-04-12T00:26:18Z")

</div>

Hello,

Below is the code for socket server in PHP

```php

    while(true)
    {
       $socketInput=socket_read($comSocket, 1024);
       
       $socketOutput = strtoupper($socketInput);
       
       socket_write($comSocket,$socketOutput);
       echo "
";
       
       sleep(1);
    }

```

in flash,

sock = new XMLSocket();  
sock.connect(“127.0.0.1”, 9999);  
[//sock.send](https://sock.send)(“hello \0”);

while(1)  
{  
sock.send(“hello \0”);  
}

sock.onData = function(data) {  
trace(data);  
}

sock.onClose = function() {  
trace(“ended”);  
}

When i connect i should keep on getting “HELLO”. But, the above code is not working. Flash stops because of while loop. Can someone tell me the correct way of writting? When i removed the while loop, i was getting only one “HELLO”

Thanks
