i want to know how to send data using the AMF format from my flex AIR project to a socket written in Java. I am getting CorruptedStreamException when sending data using writeUTFBytes() methods. Has anyone experienced similar problems? Also can AMF be used only if i am using LCDS only?
private SimpleServer(int port)
{
System.out.println(">> Starting SimpleServer on port " + port);
try
{
socket = new ServerSocket(port);
incoming = socket.accept();
objectInputStream = new ObjectInputStream(incoming.getInputStream());
objectOutputStream = new ObjectOutputStream(incoming.getOutputStream());
boolean done = false;
while (!done)
{
Object obj = objectInputStream.readObject();
System.out.println( obj.toString() );
if(obj == null)
{
done = true;
incoming.close();
}
}
}
catch (Exception e)
{
System.out.println(e);
}
}
And my as3 function to send data to the server is
private function onSendClick():void
{
var host:String = "10.87.118.8";
var port:int = 9090;
var socket:Socket = new Socket();
trace("Connect");
socket.connect(host, port);
trace("write");
socket.writeUTFBytes("HelloSocket");
trace("flush");
socket.flush();
}