Flash 客户端 XMLSocket 未连接到服务器 [英] Flash client XMLSocket not connecting to server

查看:34
本文介绍了Flash 客户端 XMLSocket 未连接到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Flash 客户端,我想连接到服务器.两者都使用本地主机和端口 50000,所以不应该有任何跨域问题.我还在发布设置中设置了仅访问网络.当我调用 XMLSocket 连接时,服务器似乎获得了一个新连接.但是,不会使用 success=true 调用 XMLSocket.onConnect 回调.

I have a Flash client that I want to connect to a server. Both are using localhost and port 50000 so there shouldn't be any cross-domain problems. I also set Access Network Only in the publishing settings. When I call the XMLSocket connect, the server seems to get a new connection. But, the XMLSocket.onConnect callback is not called with success=true.

对可能出错的地方有任何想法吗?

Any ideas on what may be wrong?

这是用于创建套接字的 ActionScript.

Here's the ActionScript for creating the socket.

 function myOnConnect(success) {
    if (success) {
        trace ("Connection succeeded!")
        inputText.text = "open";
//      socket.send("1
");
        gotoAndPlay(2);
    } else {
        trace ("Connection failed!")
        inputText.text = "failed";
    }
}


btnConnect.onRelease = function()
{
    inputText.text = "started";


    result = socket.connect("localhost", 50000);


}

socket = new XMLSocket();
socket.onConnect = myOnConnect;

推荐答案

这最终成为一个安全问题.当使用 XMLSocket 时,Flash Player 增加了安全性.Flash Player 现在在端口 843 上查找策略文件.另一种方法是让 swf 使用调用 Security.loadPolicyFile() 来查找策略文件.如果文件存在并且所有安全设置都允许 XMLSocket,则创建连接.

This ended up being a security problem. The Flash Player has added security when a XMLSocket is used. The Flash Player now looks for a policy file on port 843. An alternative is to have the swf look for the policy file using the call Security.loadPolicyFile(). If the file exists and all the security settings permit the XMLSocket, then the connection is created.

查看 关于政策文件的 Adob​​e 文章 和更多信息此处.这是另一篇关于策略文件的好文章关于策略文件.

Check out the Adobe article on Policy files and more info here. This is another good article about policy files.

这是最终对我有用的策略文件.它完全没有限制性.但是,我想我可以让事情顺利进行,然后再把它们做好.

Here is the policy file that finally worked for me. It is not restrictive at all. But, I figured I get things working and then make them right.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">

<!-- Policy file for xmlsocket://socks.example.com -->
<cross-domain-policy> 

   <!-- This is a master socket policy file -->
   <!-- No other socket policies on the host will be permitted -->
<!--   <site-control permitted-cross-domain-policies="all"/> -->

   <!-- Instead of setting to-ports="*", administrator's can use ranges and commas -->
   <!-- This will allow access to ports 123, 456, 457 and 458 -->
   <allow-access-from domain="*" to-ports="*" secure="false"/>

</cross-domain-policy>

这篇关于Flash 客户端 XMLSocket 未连接到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆