You are using UDP? Then the behaviour is totally correct. In UDP you have no guarantee in what order you receive sent packages.
http://www.cafeaulait.org/course/week12/35.html
You have to add something like a sequence number.