0 Replies Latest reply on Mar 5, 2008 5:06 AM by Sunilnairg

    XMLSocket Class

    Sunilnairg
      My Flex Application is using XMLSocketClass for communicating with Webserver. But connection cannot be established. I am not getting any error message.
      I am using the follwing code for establishing the connection:
      =================================================================
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">

      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;
      import flash.net.Socket;
      private var socket:XMLSocket;

      private function connectToServer():void
      {
      socket = new flash.net.XMLSocket();
      socket.connect("71.222.34.91", 8002);
      }
      function sendData()
      {
      var xmlvalue:String=txtData.text.toString()
      var xmlfile:String="<command>GetRevision</command>"
      socket.send(xmlfile);
      }
      private function getData()
      {
      socket.addEventListener(DataEvent.DATA, onData);
      }
      private function onData(event:DataEvent):void {
      trace("[" + event.type + "] " + event.data);
      }
      ]]>
      </mx:Script>

      <mx:HBox width="80%" horizontalAlign="center">
      <mx:TextInput id="txtData" name=""/>

      <mx:Button id="btnConnect" label="Connect" click="connectToServer();btnConnect.enabled = false"/>
      <mx:Button id="btnSend" label="Send Data" click="sendData()"/>
      <mx:Button label="getData" id="btnGet" click="getData()"/>


      </mx:HBox>

      </mx:Application>
      ====================================================================

      Please help me to handle this error.