0 Replies Latest reply on Dec 31, 2010 5:19 AM by Sarfraz07

    Datagram socket is not working



      I made a datagram socket and try to send a byte array. but when I called socket.send method it returned an error that an operation is attempted on invalid socket. What I am missing


      here is my code...


      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="480" height="262">







      private var udp:DatagramSocket = new DatagramSocket();

      private var address:String = "";

      private var port:uint = 200;




      private function OnSend():void


        udp.addEventListener(DatagramSocketDataEvent.DATA, RecvUdpDataHandler);

        var byteArray:ByteArray = new ByteArray();

        byteArray.endian = Endian.LITTLE_ENDIAN;

        byteArray.writeMultiByte("dvcrNetshare", "US-ASCII");



        udp.send(byteArray, 0, byteArray.length, address, port);





      private function RecvUdpDataHandler(obj:DatagramSocketDataEvent):void


        var str:String = obj.srcAddress;

        var srcport:int = obj.srcPort;






      <mx:Button x="206" y="134" label="Send" click="OnSend()"/>