AS3 Sockets - Policy Files

限于喜欢 提交于 2019-12-11 04:19:49

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/12256896/as3-sockets-policy-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!