Topic: Game Programming /
[Solved]Help with socket policy files.
I’ve written a C sharp server program and a as3 client program. They work fine when I run the flash client in debug inside IDE, but not when I move the client anywhere which I’ve discovered is because I need to send a policy file to the flash client. However, after the server sends the policy file it executes the Socket.Receive(byte b) function but with nothing to receive, and the client never connects to the server (connect function never calls) but no error messages. My best guess is that the policy file is wrong but I’ve tried altering it in many ways, none of which have worked.
C sharp server:
private static TcpListener myLis;
private static Socket socket;
public static void Main(string args)
myLis = new TcpListener(IPAddress.Parse("192.168.0.5"), 8002);
socket = myLis.AcceptSocket();
// some code removed to keep post short-ish
Console.WriteLine("matched policy file request!");
String policyFile = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">" +
"<site-control permitted-cross-domain-policies=\"all\"/>" +
"<allow-access-from domain=\"*\" to-ports=\"*\" secure=\"false\"/>" +
"<allow-http-request-headers-from domain=\"*\" headers=\"*\" secure=\"false\"/>" +
Char characterList = policyFile.ToCharArray();
byte toSend = new Byte[characterList.Length];
for ( int po = 0; po < characterList.Length; po ++)
toSend[po] = (byte) Convert.ToByte(characterList[po]);
// code that was here received and read 3 bytes sent by client to check connection is working
Flash Client simply connects to server and sends 3 bytes on the connect event. I have been running the client by right-click menu, open with internet explorer.
Thank you for your time.