0 Replies Latest reply on Aug 9, 2010 11:17 PM by AlexO_o

    Help, socket get incomplete text from server.


      I need help for using socket. If you know how to resolve my issues, please help me. I search my problem by many many keywords in Google, I didn't find any helpful information.

      I am developing an application, Flex client - Java server. The Java server can send right text, for example, I sent 5118 bytes to the client many times, the server side printed 5188 bytes in all these tests. But the Flex client cannot receive the full data frequently.

      Here is my data handler code, it's normal.

           var msg:String = "";
           while(socket.bytesAvailable != 0)
                msg += socket.readUTFBytes(socket.bytesAvailable);
           // decrypt here
           // var dat:String = decrypt(StringUtil.trim(msg));          
           var idx:int = msg.indexOf("\n");
           var id:String = msg.substr(0, idx);
           var response:String = msg.substring(idx+1);
           if (commands[id] != null) 
                var cmd:ICommand = commands[id] as ICommand;
                commands[id] = null;

      I send long XML text from server side, and Flex client receives it and parses and process the response. Client socket frequently receives incomplete XML text. So errors occured. And.. only occurs when receiving long text. It's not network problem, I do this local host.

      I don't know why. Is there any mistake I made in data handler? please help me