Flash not working in browser

Hello,

I hope i am posting in the right place.

I wrote a socket script

server side,


   <?php

// define TCP port & local host
$port=10000;
$host='127.0.0.1';
set_time_limit(0);
// create low level socket
if(!$socket=socket_create(AF_INET,SOCK_STREAM,0)){
    trigger_error('Error creating new socket',E_USER_ERROR);
}
// tie up socket to TCP port
if(!socket_bind($socket,$host,$port)){
    trigger_error('Error binding socket to TCP port',E_USER_ERROR);
}
// begin listening connections
if(!socket_listen($socket)){
    trigger_error('Error listening socket connections',E_USER_ERROR);
}
// create communication socket
if(!$comSocket=socket_accept($socket)){
    trigger_error('Error creating communication socket',E_USER_ERROR);
}

    $i=0;
    while(true)
    {
       $socketInput=socket_read($comSocket, 1024);
       
       $socketOutput = strtoupper($socketInput);

       socket_write($comSocket, $socketOutput);
       
       usleep(250);

       $i++;
    }

// close sockets
socket_close($comSocket);
socket_close($socket);

?>

In the flash,

[script]
sock = new XMLSocket();
sock.connect(“127.0.0.1”, 10000);

sock.send("kirupa
");

sock.onData = function(data) {
txtData1.text = data;
txtData2.text = data;
txtData3.text = data;
txtData4.text = data;
txtData5.text = data;
txtData6.text = data;

sock.send("kirupa 

");
}

[/script]

I have a few questions,

  1. When i run this (by opening swf) it works. But when i open it in a browser it is not working.

  2. When i change the value of $socketOutput,

    $socketOutput = strtoupper($socketInput);

    to some other value

    example,

$socketOutput = “kirupa2”;

it is not working.

  1. Is it necessary to send values from client to receive output from server?
    Is it not possible to send request once and the server keeps on sending values until the client closes the browser? if it is, please provide some sample script/url which would help me in doing it.

Thanks