【发布时间】:2024-04-23 16:00:01
【问题描述】:
我正在为我的应用程序编写 Java 服务器。 当我调试我的 Flash 应用程序时,一切正常。 当我发布它并使其从 localhost 加载时 - 它现在需要加载安全文件。
我将该文件作为字符串添加到我的服务器,当来自闪存的请求到来时我会传递该文件。我从请求中读取所有数据,直到结束空字节。 我没有忘记文件文本末尾的空字节。 在 Flash 应用程序中,套接字连接上有事件侦听器,因此当 Event.CONNECT 触发时,发送到服务器的第一个命令。 如我所见,此事件没有触发。我的服务器将策略文件传递给客户端,但客户端在获取策略后不会将套接字连接到服务器。
我整天都在努力解决这个问题。我已经不知道该怎么做了。请帮帮我。
String crossdomeinFile = "<?xml version=\"1.0\"?>\r\n" + "<cross-domain-policy>\r\n" + "<allow-access-from domain=\"*\" to-ports=\"*\" />\r\n" + "</cross-domain-policy>\r\n" + "\0";
System.out.println(crossdomeinFile);
ByteBuffer r = ByteBuffer.allocate(crossdomeinFile.getBytes().length);
r.put(crossdomeinFile.getBytes());
chanel.write(r);
【问题讨论】:
-
向我们展示不起作用的代码。
-
String crossdomeinFile = "<?xml version=\"1.0\"?>\r\n" + "<cross-domain-policy>\r\n" + "<allow-access-from domain=\"*\" to-ports=\"*\" />\r\n" + "</cross-domain-policy>\r\n" + "\0"; System.out.println(crossdomeinFile); ByteBuffer r = ByteBuffer.allocate(crossdomeinFile.getBytes().length); r.put(crossdomeinFile.getBytes()); chanel.write(r);code -
无法格式化,抱歉。所以在这里我发回闪存套接字策略。一段时间后,它得到了政策,我得到了这个:[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"]
-
我使用的是同一个端口,6969。
-
上面的代码是我在java服务器中的。在该代码之前,我从闪存读取请求直到 \0 字节。