1

I have a mini server listening on port 843 for <policy-file-request/> I then send down the following:

<cross-domain-policy>
<allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

On my flash side the connection code looks like

m_socket = new Socket("127.0.0.1", 4600);
m_socket.addEventListener(ProgressEvent.SOCKET_DATA, OnSockData);

m_socket.writeUTFBytes(String.fromCharCode(255) + String.fromCharCode(0));
m_socket.flush();

I have a separate server listening on port 4600 that expects to get the char 255 from the client but it is never sent. The connection on port 4600 is established but the data is never sent.

The mini server on port 843 is successfully getting the connection from the client and sending the policy file as well.

So either there is some problem with the policy file submission (which I'm not sure how to check in AS3). Or option 2 is that for some reason data is being lost during the initial connection process.

P.S. If I don't run the mini server on port 843 the server on port 4600 will receive the policy file request (as per AS3 protocol).

I would appreciate any tips on what to check here. I'm not sure what is going wrong. I had been doing everything through the flash debugger and didn't need the policy file request stuff until now.

Josh Brittain
  • 2,162
  • 7
  • 31
  • 54
  • After tweaking things a little bit I can confirm that the initial data is lost but if I resend the same data a few seconds later it works fine. Is there some callback to know when a policy file has been accepted and it is safe to send data across the socket? – Josh Brittain Sep 04 '12 at 05:24

1 Answers1

2

You might need the full XML with doctypes. Also, you might need to actually restrict the port as well. Try this:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy><allow-access-from domain="*" to-ports="4600" /></cross-domain-policy>

EDIT: try m_socket.addEventListener(Event.CONNECT, connectHandler); and then create the connectHandler function to send your data.

Femi
  • 64,273
  • 8
  • 118
  • 148
  • Thanks for the suggestions. Sadly after making those changes I still have the same problem. – Josh Brittain Sep 04 '12 at 05:17
  • That did it! Adding the event listener for connection and then sending the data will assure that no data is lost while waiting for the policy file to be sent. Thanks! – Josh Brittain Sep 04 '12 at 06:18