;

PDA

Click to See Complete Forum and Search --> : [RESOLVED] XMLSocket Policy File Help?


HighSchoolSux
04-20-2009, 09:04 PM
It seems that my code can connect perfectly locally but does not connect from a website. I think its because of the policy file.
I have no idea how to call a policy file using KoolMoves.
I also have no idea where the policy link code should go.. At the beginning of the code? At the end?
I tried:

System.loadPolicyFile("http://09.isgreat.org/server/flashpolicy.xml");
Security.loadPolicyFile("http://09.isgreat.org/server/flashpolicy.xml");
System.Security.loadPolicyFile("http://09.isgreat.org/server/flashpolicy.xml");

None of these have worked and I still get a "Socket established, but connection could not be made.".
What am I doing wrong?
this is my whole code:

System.loadPolicyFile("http://09.isgreat.org/server/flashpolicy.xml");
socket = new XMLSocket()
socket.onConnect = myOnConnect
socket.onClose = function (){
statusText.text = "Connection terminated by server."
}

if (!socket.connect("MYIP",80))
{
statusText.text = "Connection failed! Could not establish socket."
}


function myOnConnect(success)
{
if (success)
{
statusText.text="You are connected."
}
else
{
statusText.text = "Socket established, but connection could not be made."
}
}

I know my port 80 is not blocked and my IP address is right and everything.
THANK YOU for any help. =)

w.brants
04-22-2009, 01:47 AM
I'm not exactly sure but as far as I know you need a socket server.
The problem is not directly related to KM. It all has to do with Flash Player security restrictions. The correct syntax is :

Security.loadPolicyFile("http://09.isgreat.org/server/flashpolicy.xml");

HighSchoolSux
04-22-2009, 09:06 PM
OMG. I found the problem!! Can someone delete this thread? Thanks.

blanius
04-22-2009, 11:30 PM
I could delete it but it's better to leave it marked Resolved. You never know when someone else will need this

HighSchoolSux
04-23-2009, 01:41 AM
then its best I say how I fixed it..
You don't need the link!!
You do not need this:
System.loadPolicyFile("http://09.isgreat.org/server/flashpolicy.xml");

I just had to capture the packet sent by the swf with my server program to make it work.
I used VB6.
This is the code for VB6 to capture the policy file request and send the response needed for it to connect:


Case "<policy-file-request/>"
SendData Index, "<cross-domain-policy><allow-access-from domain=" & Chr(34) & "*" & Chr(34) & " secure=" & Chr(34) & "false" & Chr(34) & " to-ports=" & Chr(34) & "*" & Chr(34) & "/></cross-domain-policy>"


This will make it connect online!!