Receiving Data : Socket : Network Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Network » Socket »

 

Receiving Data


 
Socket read methods for various datatypes

package {
  import flash.display.Sprite;
  import flash.events.ProgressEvent;
  import flash.net.Socket;

  public class SocketExample extends Sprite {
  
    private var socket:Socket;
  
    public function SocketExample(  ) {
      socket = new Socket(  );
      
      socket.addEventListenerProgressEvent.SOCKET_DATA, onSocketData );

      socket.connect"localhost"2900 );
    }

    private function onSocketDataevent:ProgressEvent ):void {
      trace"Socket received " + socket.bytesAvailable + " byte(s) of data:" );

      while socket.bytesAvailable ) {
        var data:int = socket.readByte(  );
        tracedata );
      }
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Network
» Socket