0 Replies Latest reply on May 4, 2010 2:42 AM by v.detez@gmail.com

    Socket problem

    v.detez@gmail.com

      Hello,

      In order to have a HTTP response and show it in real time, I am decided to use socket.

       

      1. In my code: TO SEND DATA

        private function send():void

                      {

                      socket.writeUTFBytes('GET /test/stepIIS.py?env=PRD&stepname=electrabel_be&count=2&loglevel=1 HTTP/1.1\r\n');

                      /*socket.writeUTFBytes('GET /test/stepIIS.py HTTP/1.1\r\n');*/

          socket.writeUTFBytes('Host: 127.0.0.1:1081\r\n');

          socket.writeUTFBytes('Connection: Keep-alive\r\n\r\n');

          socket.flush();

         }

      In my code: TO READ DATA

      private function onSocketData(event:ProgressEvent):

      {

      while (socket.bytesAvailable)    

                      {

                     

                      try

                      {

                      var b:int = socket.readUnsignedByte();

                      txtResponse.text += String.fromCharCode(b);              

                      }catch(e:EOFError)

                      {

                      //Alert.show(

                      }

        }

      }

       

      However in my txtResponse.text (area), after the header I have got a int (34,1,7,1b,5e... representing the number of characters)+ part of response

       

      2. My question is : How can I skip the int representing the length of my next part of the response?

       

      thks a lot

       

      Valery

       

      HTTP/1.1 200 OK

      Date: Tue, 04 May 2010 09:37:57 GMT

      Server: Apache/2.2.14 (Win32) mod_python/3.3.1 Python/2.5

      Keep-Alive: timeout=5, max=100

      Connection: Keep-Alive

      Transfer-Encoding: chunked

      Content-Type: text/plain

       

       

      34

      04-05-2010 11:37:57 -     1 http://www.electrabel.be

      1

       

      7

      bonjour

      1b

      04-05-2010 11:37:57 - Try 1

      1

       

      5e

      04-05-2010 11:37:57 -     Calling tellme page at www.electrabel.be/code/asp/globals/tellme.asp ...........