title: Security Sandbox Violation, can't connect to Server via Socket
body: <p>Before I start I should state I have read it all, I was following <a href="https://stackoverflow.com/questions/5678058/security-sandbox-violation-lack-of-policy-file-permissions/5678960#5678960">this</a>, <a href="http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html" rel="nofollow noreferrer">this</a> and <a href="http://haxe.org/forum/thread/2260" rel="nofollow noreferrer">this</a> (and more...) and still I cannot connect to our running server via Socket over the internet.</p>
  
  <p>Here is what I try to in AS3:</p>
  
  <pre><code>        var host :String = "192.168.2.11";
          Security.allowDomain(host);
          Security.allowInsecureDomain(host);
          Security.loadPolicyFile("xmlsocket://" + host + ":" +  "843");
  
          // TTS server socket
          _socket = new Socket();
          _socket.addEventListener(Event.CLOSE, handleClose);
          _socket.addEventListener(IOErrorEvent.IO_ERROR, handleError);
          _socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleSecError);
          _socket.addEventListener(ProgressEvent.SOCKET_DATA, handleIncomingData);
          _socket.addEventListener(Event.CONNECT, handleConnect);
          _socket.connect(host, 1337);
  </code></pre>
  
  <p>As you can see, the host is a local address, but that shouldn't matter as long as I am in this local network. And I am, since this does work from my IDE (FD4).
  Also, the swf is on the same server as the application it tries to connect to, but on another port.</p>
  
  <p>The policy file the server sends (we have tried both from port 843 and 1337) is the following:          </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt; 
  &lt;!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"&gt; 
  &lt;cross-domain-policy&gt; 
      &lt;allow-access-from domain="*" to-ports="*" /&gt; 
  &lt;/cross-domain-policy&gt;
  </code></pre>
  
  <p>We can see from the log output of the server that this is really sent to the connecting socket. A null byte is of course sent after the xml data. And after that, the server closes the connection. However, it seems that Flash somehow does not like it, as "Error #2048" still appears after ~3 seconds.</p>
  
  <p>We're really out of ideas here...</p>