Skip to main content
Participant
December 6, 2013
Question

ServerSocket. Is there a way to know the total size of arriving data?

  • December 6, 2013
  • 0 replies
  • 177 views

Hi. I have two apps: a server and a client.

Server sends to client different types of data inside an Object:

var data:Object  = {

     bdata1 : bitmapdata_A,    

     bdata2 : bitmapdata_B,   

     bdata3 : bitmapdata_C,

}

clientsocket.writeUTF( 'Hello I'm sending some bitmaps!');

clientsocket.writeObject(data);

clientsocket.flush();

... client receives it:

socket.addEventListener(ProgressEvent.SOCKET_DATA, socketData);

private function socketData(e:ProgressEvent):void {


     trace(server.readUTF());

     var data:Object = server.readObject();

 

}

Problem: When the object "data" is a simple object (strings, number, boolean), the process is successfully,

but when I try to send bitmapdata, the program broke, because client try to read an object that is not completed transferred.

There is a way to know the size of the incoming data, and handle it when the transfer is finished? Thanks.

Message was edited by: que_onda

This topic has been closed for replies.