Parse network packets (UDP, to be specific)
Hi,
I am working on some networking code and what puzzles me is that I have been unable to find any sensible way of parsing the payload of UDP packets. I need to get to some 32 bit integers (longs in Java), some bit values and a few 3 bit and 5 bit values in these packets.
The best I have come up with is to treat the payload as byte[] and do tons of bitshifting, masking and casting.
Is there a clever way of doing this, or a library that does it for me, that I have overlooked? Something to make this less painstaking? Ideally I'd like to define the structure, feed the packet to a parser and have it come out as something with structure on the other end. Pretty much like you do this in C.

