Sending crossdomains policy to flash via node js on TLS connection
<p>I have a client which is in flash as3.
I got 2 server, one main for the flash client and a socket policy server.</p>

<p>I run the socket policy server on port 843 and my client on any port X for example.</p>

<p>Now when i connect with my flash client, using this:</p>

<pre><code> Security.loadPolicyFile("xmlsocket://domain.com:port");
 SecureSocket.connect(ip, port);
</code></pre>

<p>It actually connect first to my policy socket server, send a policy-file-request line and receive the one i am sending using my server which look like this:</p>

<pre><code> tls.createServer(options, function(sock) {
    sock.on('data', function(data) {
            console.log('Data receveid: '.cyan + data + ' from ' + sock.remoteAddress);
            if (data == "&lt;policy-file-request/&gt;\0") {
                    sock.write('&lt;?xml version="1.0"?&gt;&lt;!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt;&lt;cross-domain-policy&gt;&lt;site-control permitted-cross-domain-policies="all"/&gt;&lt;allow-access-from domain="*"&gt;&lt;/cross-domain-policy
                    console.log('Sent policy file to: '.green + sock.remoteAddress);
            }
 ...
</code></pre>

<p>After that, the connection is closed automatically. Then it try to connect to my real server and send to server the policy-file-request line again then connection close. I really dont know what to do from now on ive been trying all days and searching around the web. Anyone got an idea of what i am missing?</p>