blue-genie
asked on
TCP socket connection Flex 3 - funny square returned.
i'm busy fiddling around with flex as I've decided to do my next project in flex - just for fun.
i found some code on how to connect to a TCP socket .
it returns values like this
<?xml version="1.0"?>
<Msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ACK fromSystem="blah" msgType="Connect" />
</Msg> <--- it has a square at the end of it. you can't really see it here
anyone have any idea why its doing that and what i have to do to get rid of it?
i found some code on how to connect to a TCP socket .
it returns values like this
<?xml version="1.0"?>
<Msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ACK fromSystem="blah" msgType="Connect" />
</Msg> <--- it has a square at the end of it. you can't really see it here
anyone have any idea why its doing that and what i have to do to get rid of it?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private var socket:Socket = new Socket();
private function load():void{
socket.connect('127.0.0.1', 8080);
socket.addEventListener(Event.CONNECT, connectedHandler);
socket.addEventListener(ProgressEvent.SOCKET_DATA, inputDataHandler);
}
private function inputDataHandler(event:ProgressEvent):void {
var bytesLoaded:int = socket.bytesAvailable;
var str:String = socket.readUTFBytes(socket.bytesAvailable);
myT.text+=str;
}
private function connectedHandler(event:Event):void {
socket.writeUTFBytes("GET /sockets.html HTTP/1.0\n\n");
socket.flush();
}
]]>
</mx:Script>
<mx:Button click="load()" label="load"/>
<mx:TextArea x="10" y="30" width="680" height="395" id="myT"/>
</mx:Application>
sample.bmp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for that information.