views:

60

answers:

1

I am using actionscript to connect to my socket server, but I always got <policy-file-request/> sent from actionscript and after that the conneciton is closed. The code in actionscript is:

            protected function connect_to_server_btn_clickHandler(event:MouseEvent):void
        {
            Security.loadPolicyFile("http://192.168.0.198/crossdomain.xml");
            socket = new Socket();
            socket.addEventListener(Event.CONNECT, onConnect);
            socket.connect("192.168.0.198", 9999);
        }

The content of crossdomain.xml:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt;
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

The swf and it's wrapper html are all put under http://192.168.0.198/bin-debug/, and the crossdomain.xml file is loaded by actionscript successfully(thru packet capture tool).

I think supposely I shouldn't get <policy-file-request/> if I provided the crossdomain.xml? Thanks in advance!

+1  A: 

Here is tutorial how to solve http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html

Flash Player checks for a policy file server (port 843 by default), or if necessary, on the socket you're opening (for you, port 2222).

Also, read this.

Eugene
you can also find some opensource project based on python, which releases this server, and answering with your custom crossdomain file on 843 port. Like this one http://www.webmechs.com/actionscript-3-tutorials/actionscript-echo-server.html You could even find some deb/rpm package.
Eugene