Okay, I am attempting to set up a socket connection to a program I have made (simply printf things that are send via sockets to the screen and senda a message back, using Python) with my Flash frontend (to make it nice and able to run from the browser). The server (python) side is working fin, it recieves everythign like it is supposed to, and replies too. The problem is that when I am not running the flash portion within the Flash sandbox (Flash program using CTRL+Enter) the connection fails.
I have read that they (Adobe) has added something called Policy Files to their security measures after Flash Player 7.something, and as such I have attempted to implement one (that is stored on the client computer and connected to/read by the flash swf so it knows that it is allowed to connect).
Here is a look at my Policy File:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
I think it should work fine (as it is copied from adobe’s hlp files on policy files and modified to allow everything).
Here is the code that I am using with my Flash swf file:
System.security.loadPolicyFile("file:///C:\a_python\python_test_apps\socket_04_chat_test\crossdomain.xml");
var sock:XMLSocket = new XMLSocket();
sock.connect('localhost', 2727);
sock.onConnect = function(myStatus:Boolean){
if(myStatus){
txt.text += "Connected
";
trace("Connected");
}
else{
txt.text += "Connection Failed
";
trace("Connection failed");
}
}
sock.onData = function(msg:String){
txt.text += "Recieved: "+msg+"
";
trace("Recieved: "+msg);
}
sock.onClose = function(){
txt.text += "Connection Closed.";
trace("Connection Closed");
}
sock.send("testing it out - Flash style :)");
Where “[[COLOR=#800080]file:///C:\a_python\python_test_apps\socket_04_chat_test\crossdomain.xml[/COLOR]](file:///C:/a_python/python_test_apps/socket_04_chat_test/crossdomain.xml)” is the absolute path to the policy file on my harddrive, and the server (python) script is in the same folder (which, if I have read thigns correctly is okay).
The problem is, that whenever I attempt to run the swf from the web the connection fails to work, and the server only prints out this:
<policy-file-request/>
It I am not mistaken I have already told the swf where it can find the policy file.
Now, what I need some help on it getting this to work, assuming that it is even possible in the first place (and assuming it isn’t please tell me so I can stop wasting my time on it).
Any Thoughts?