M
me
Hi there
I'm writing a messaging interface that takes a stream of binary data
from a socket, interprets it according to a message specification (field
names/lengths etc), and then acts upon the message.
My original design was to read from the socket until i got a code that
indicates the start of a message, then read MESSAGE_LENGTH bytes, then
pass it to another class for interpretation and actioning, thus getting
a nice seperation between the network interface and the actual data.
The problem is that some fields in the message have Field Extension
bits. In short, this means that if the LSB of the field is 1, then there
are extra bytes inserted in the message immediately afterwards.
So my problem is how do I interpret the message on the fly (in order to
read the correct number of bytes), while still maintaining seperation
between reading of the message bytes and their interpretation?
Cheers
pjw
I'm writing a messaging interface that takes a stream of binary data
from a socket, interprets it according to a message specification (field
names/lengths etc), and then acts upon the message.
My original design was to read from the socket until i got a code that
indicates the start of a message, then read MESSAGE_LENGTH bytes, then
pass it to another class for interpretation and actioning, thus getting
a nice seperation between the network interface and the actual data.
The problem is that some fields in the message have Field Extension
bits. In short, this means that if the LSB of the field is 1, then there
are extra bytes inserted in the message immediately afterwards.
So my problem is how do I interpret the message on the fly (in order to
read the correct number of bytes), while still maintaining seperation
between reading of the message bytes and their interpretation?
Cheers
pjw