XMLSocket exceptions
I am trying to send some data from XMLSocket in flex script to TCP server socket on localhost, port 12345 : 开发者_开发技巧
import flash.net.XMLSocket;
import flash.system.System;
private var socket:XMLSocket;
private function xmlConnectHandler( event:Event ):void {
txtInfo.text += "xmlConnectHandler";
socket.send( "<test>Connection from flex<test/>" );
}
private function XmlConnect():void
{
socket = new flash.net.XMLSocket();
socket.addEventListener(Event.CONNECT, xmlConnectHandler);
socket.connect(null, 12345);
}
]]>
</fx:Script>
<mx:VBox>
<s:Label id="lblStatus"/>
<mx:Button label="Test" click="XmlConnect()" />
<mx:TextInput id="txtInfo" />
</mx:VBox>
I have
Error #2044: Unhandled ioError:. text=Error #2031: Socket Error. at Main/XmlConnect() at Main/___Main_Button1_click()
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file:///C:/flex/src/Main.swf cannot load data from :12345. at Main/XmlConnect() at Main/___Main_Button1_click()
Is this a security problem? This is confusing: I thought I am trying to connect to "local domain" in the case of localhost connection with "socket.connect(null, 12345)", do i still need a policy file anyway? Thank you, -V
You should read up on XMLSocket Policy Files.
精彩评论