0

I'm having this problem when i want to send using socket a message...

textField.addEventListener(KeyboardEvent.KEY_DOWN,enterHandler);

  function enterHandler(event:KeyboardEvent):void{
        if(event.keyCode == Keyboard.ENTER ){
            socket.writeUTF(textField.text);
            socket.flush();
            trace(textField.text); //the output is what input text is, so the input field is right
        }
    }

The error is this : Error: Error #2030: End of file was encountered. at flash.utils::ByteArray/readUnsignedByte() at socket_fla::MainTimeline/closeListener()

Any Idea?

Edit: After checking the Java server (RedDwarf) that the client is connected to, it shows that the Message is received, then SEVERE: unknown opcode 0x61 Tried googling it, nothing..

4
  • The error has nothing related to the posted code. There error is telling me you have an open brace "{" somewhere without the corresponding closing brace "}"
    – The_asMan
    Jun 26, 2013 at 15:54
  • Not really, i double checked... This error is shown after I compile the code, when i press enter in the input field.. Jun 26, 2013 at 21:43
  • Ah its end of file on the data set. lol I misread it. I am not familiar with red dwarf but I get the feeling that when the data is sent it is not adding a null character at the end. the error states it is in closeListener which you did not post. also try putting socket.writeByte(0); before you flush.
    – The_asMan
    Jun 27, 2013 at 20:45
  • here it is : function closeListener (e:Event):void { buffer.position = buffer.length - 1; var lastByte:int = buffer.readUnsignedByte(); if (lastByte != main.EOT) { return; } buffer.length = buffer.length - 1; loader = new Loader(); loader.loadBytes(buffer); loader.contentLoaderInfo.addEventListener(Event.INIT, assetInitListener); } function assetInitListener (e:Event):void { addChild(loader.content); out("Asset initialzed."); } Jun 27, 2013 at 22:31

1 Answer 1

0

this question may be caused when you haven't addEventListener(ProgressEvent.SOCKET_DATA, data) on the socket in the server. you must read data after you have already got it.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.