Re: Bit operations on bytes or chars
Vlad Dogaru wrote:
I have a homework to implement RUDP[1] in Jasper[2]. Now, Jasper uses
RUDP = reliable UDP. Cool, thanks for the pointer, I didn't know such a
thing existed.
a specific format for packages, namely all data is a String (which
makes sense, since it abstracts all headers and the like). However, my
Ugh. No, it doesn't make sense to use Strings. They should use classes
with the UDP fields defined appropriately. Stuffing random data into a
String is utter laziness and horrible design.
homework is to also implement the package header; hence my char
troubles. I agree that it is not a very healthy way to work, and I
blame the teacher who gave the homework, but I am unable to find a
different solution.
Between your teacher, and whatever grad student that wrote the mess that
is Jasper, I'd consider a new school.
You may want to check out a book by Douglas Comer called Internetworking
With TCP/IP, Volume II. It contains a full TCP implementation. At no
point does he do anything lazy like stuff fields in to byte arrays. He
defines a full, complete, well documented C struct for each and every
packet he uses. Much better design philosophy, imo.