Sockets
Hi,
I'm trying to establish a socket connection to the remote server with an mobile application written in flash builder. I'm using flex 4.5 sdk.
While running the code in mobile emulators, the socket connection is working. But after deploying the application to the phone, I get an #2031 error.
the source code is the following:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Style>
@11909012 s "library://ns.adobe.com/flex/spark";
global {
fontSize: 32;
}
</fx:Style>
<s:layout>
<s:VerticalLayout horizontalAlign="center" paddingTop="20"/>
</s:layout>
<s:TextInput id="t" text="test test"/>
<s:Button label="create notification">
<s:click>
<![CDATA[
var s:Socket = new Socket();
s.connect("serverName", 9999);
s.addEventListener(Event.CONNECT, function(event:Event):void {
trace('connected!');
t.text = "connected";
(event.currentTarget as Socket).writeInt(1);
(event.currentTarget as Socket).writeUTF(t.text);
(event.currentTarget as Socket).flush();
(event.currentTarget as Socket).close();
});
s.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void {
trace('error! ' + event.errorID);
t.text = "error! " + event.errorID;
});
s.addEventListener(ProgressEvent.SOCKET_DATA, function(event:ProgressEvent):void {
trace('progress ');
});
]]>
</s:click>
</s:Button>
</s:Application>
What am I doing wrong here?
