Hey how come he gets a medal
Yeah. You have to .flip() your bytebuffer before sending and after receiving it. lolCool, glad to see you got it working. Sorry I wasn't able to look at it until you already had it done.
But that's just weird, why call "flip()" when you receive it? O.o
You need to copy data out in the reverse order it was sent. You can think of it sort of like this:
Actually that is totally wrong.
On a reliable connection packets arriove in the order they were sent. In a non-reliable, they arrive in any order.
But within the packet you need to read the data out in the same order you wrote it in. If you actually RTFM you find out that flip doesnt do what you think it does.
Flips this buffer. The limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded.
When you finish writing into the buffer, you are in "just written" state. Your current position is the byte just after the last one you wrote (the next place to write if you continued writing) and your limit is the last byte in the buffer.
Flip puts you into "ready to read state" by putting the current position into the limit so you cannot read past what you wrote, and then putting 0 into current position as this is the place you want to start reading from.