Sockets problem :: Error #2048

Hi everyone!

When I test my flash game in IDE, everything works perfect, but when I test it through web browsers, Socket is unable to connect.

For makin connection I do in as3:

var MP_SERVER_IP:String="xxx.xxx.xxx.xxx";
var MP_SERVER_PORT:int=10014;
var MP_socket:Socket = new Socket();

Security.loadPolicyFile("http://"+MP_SERVER_IP+"/crossdomain.xml");

MP_socket.connect(MP_SERVER_IP, MP_SERVER_PORT);

When flash trying to get crossdomain manually at the port, in server logs I got:

-= xxx.xxx.xxx.xxx Server =-

New client connected: xxx.xxx.xxx.xxx (Total 1 clients)
 -- Client said: <policy-file-request/>&#65533;
client requested crossdomain.xml sending...
 -- Client said: 
client disconnected.

and after 5-10 seconds when it made attempt to connect securityError appears:

[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"]

Full code of php file, what starts server:

<?

    header('Content-Type: text/plain;');
    error_reporting(E_ALL ^ E_WARNING);
    set_time_limit(0);
    ob_implicit_flush();
	ob_end_flush();
	
    
    echo "-= xxx.xxx.xxx.xxx Server =-

";
	
	include("adm.php");
	$address = '0.0.0.0';
	$port    = 10014;
	$max_clients = 128; 
	
	$crossdomain = '<cross-domain-policy><allow-access-from domain="*" secure="false" to-ports="'.$port.'"/></cross-domain-policy>';


	$trrr=0;

// create a streaming socket, of type TCP/IP
    $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    
    // set the option to reuse the port
    socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1);
    
    // "bind" the socket to the address to "localhost", on port $port
    // so this means that all connections on this port are now our resposibility to send/recv data, disconnect, etc..
   // socket_bind($sock, 0, $port);
   socket_bind($sock, $address, $port) or die('Could not bind to address'); 
    
    // start listen for connections
    socket_listen($sock);

    // create a list of all the clients that will be connected to us..
    // add the listening socket to this list
    $clients = array($sock);
	
    while (true) 
	{
		@ob_flush();
        // create a copy, so $clients doesn't get modified by socket_select()
        $read = $clients;
        
        // get a list of all the clients that have data to be read from
        // if there are no clients with data, go to next iteration
        if (socket_select($read, $write = NULL, $except = NULL, 0) < 1)
            continue;
        
        // check if there is a client trying to connect
        if (in_array($sock, $read)) 
		{
            // accept the client, and add him to the $clients array
            $clients[] = $newsock = socket_accept($sock);
            
            // send the client a welcome message
            //socket_write($newsock, "no noobs, but ill make an exception :)
"."There are ".(count($clients) - 1)." client(s) connected to the server
");
			socket_write($newsock, $crossdomain, strlen($crossdomain));
			
			socket_write($newsock, $crossdomain, strlen($crossdomain));
            
            socket_getpeername($newsock, $ip);
            echo "New client connected: {$ip} (Total ".(count($clients) - 1)." clients)
";
            
            // remove the listening socket from the clients-with-data array
            $key = array_search($sock, $read);
            unset($read[$key]);
        }
        
        // loop through all the clients that have data to read from
        foreach ($read as $read_sock) 
		{
			if (false === ($data = socket_read($read_sock, 1024))) 
			{
				echo 'socket_read() failed: '.socket_strerror(socket_last_error())."
";
			} 
			
				
			echo ' -- Client said: '.$data."
";
				

            // check if the client is disconnected
			
			//echo ;
			if (strlen($data)==0 && ord($data)==0)
			//if ($data=='')
			{
                // remove client for $clients array
                $key = array_search($read_sock, $clients);
                unset($clients[$key]);
                echo "client disconnected.
";
                // continue to the next client to read from, if any
                continue;
            }
            
			 
            // trim off the trailing/beginning white spaces
			
            $data = trim($data);
			
			//if ($data == '<policy-file-request/>')
			if (substr($data, 0, 12) == substr('<policy-file-request/>', 0, 12))
			{
				echo "client requested crossdomain.xml sending...
"; 
				
				socket_write($send_sock, $crossdomain, strlen($crossdomain));
			}
			else
			{
				$ans='Beep';
				
				echo 'Sending "'.$ans.'"'."
";
				socket_write($send_sock, $ans, strlen($ans));
				//$data=$ans;
				//$trrr++;
			}
			// check if there is any data after trimming off the spaces
            if (!empty($data)) 
			{
            
                // send this to all the clients in the $clients array (except the first one, which is a listening socket)
                foreach ($clients as $send_sock) 
				{
                
                    // if its the listening sock or the client that we got the message from, go to the next one in the list
                    if ($send_sock == $sock || $send_sock == $read_sock)
                   //     continue;
                    
                    // write the message to the client -- add a newline character to the end of the message
                    socket_write($send_sock, $data."
");
                    
                } // end of broadcast foreach
                
            }
            
        } // end of reading foreach
    }

    // close the listening socket
    socket_close($sock);
?>

As server I use Ubuntu, ipv6 disabled. I’am new in servers and socket programming. Why does it not work? Hope you may know what the reason of this.