These problems drive me crazy! I read ALL questions about stackoverflow, but I'm still stuck.
My as3 program works very well, but when I finished it and put it on the server, it will start requesting this famous policy file.
AS3 script:
socket.addEventListener(Event.CONNECT, onConnect);
socket.addEventListener(Event.CLOSE, onClose);
socket.addEventListener(IOErrorEvent.IO_ERROR, onError);
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError);
socket.addEventListener(ProgressEvent.SOCKET_DATA, onResponse);
socket.connect( MYHOST, 4242 );
C # server code:
TcpListener serverSocket = new TcpListener(4242);
TcpClient clientSocket = default(TcpClient);
serverSocket.Start();
clientSocket = serverSocket.AcceptTcpClient();
NetworkStream networkStream = clientSocket.GetStream();
StreamReader read = new StreamReader(networkStream, Encoding.UTF8);
StreamWriter write = new StreamWriter(networkStream, Encoding.UTF8);
response = read.ReadLine();
if (response.Contains("policy"))
{
write.Write("<?xml version=\"1.0\"?><cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>\0");
write.Flush();
clientSocket.Close();
return;
}
So, when AS3 does not find the policy on port 843 by default (or something similar), it requests a connection directly on the same socket. My C # code shows the request and response, after which the AS3 script closes the connection. (OK) But never connect.
I tried putting this in AS3 before connecting ():
Security.loadPolicyFile( "xmlsocket://myhost.com:4242");
connect(); .
AS3, . .
, .
: - , ?
.