Posted by mzabel
on January 13, 2009 at 10:10 AM PST
I am using javax.microedition.io.Datagram to receive UDP packets. Now, I want to extract the full data buffer using the interface method getData(). But IMO, the behavior of this method is not stated clearly in the javadoc from Sun.
Several behaviors are possible:
1.) The returned byte contains only user data, starting from index 0 up to the length of the byte.
2.) In the returned byte the user data starts from index 0 up to the length (exclusive) returned by getLength(). All trailing bytes are garbage.
3.) The user data is stored from getOffset() up to getOffset()+getLength() (exclusive). All remaining bytes are garbage.
Which behavior is intended?
I have already taken a look into the implementation of phoneME, but I don't now if it is correct. On the web, I have found sample programs which rely on behavior 1) or on behavior 2). But IMO behavior 3) is correct.
Could someone clarify this point?