T
Tom
This may be more theory than code,
I am currently using a 3rd party TCP client socket tool to read in
data from a connection. The tool supports and End of Line(EOL)
character. The problem is that the data that is coming in does not
have an EOL character or set of characters. The first 4 bytes of the
data contain a set of defined characters "ABCD". The next 4 bytes
give the size of the whole packet, "0012". After that, there is a
random length of data.
Of course, the TCP tools DataIn function fires for partial messages,
which I have to assemble in a byte[] buffer, while waiting for the
rest of the message. Well I only have the length of the message to go
on. If I use the starting characters "ABCD" as the EOL, the last
message in will not get processed until another. This is to be
expected. I could count the number of characters until the message
length, copy out the message, but would then have to shift the entire
buffer to the left in case part of another message was in the previous
transmission. Or is there a natural break so that one event can not
have two separate partial TCP packets? I know that this is probably a
3rd party question.
What is a good way to deal with something like this?
Thanks,
Tom
I am currently using a 3rd party TCP client socket tool to read in
data from a connection. The tool supports and End of Line(EOL)
character. The problem is that the data that is coming in does not
have an EOL character or set of characters. The first 4 bytes of the
data contain a set of defined characters "ABCD". The next 4 bytes
give the size of the whole packet, "0012". After that, there is a
random length of data.
Of course, the TCP tools DataIn function fires for partial messages,
which I have to assemble in a byte[] buffer, while waiting for the
rest of the message. Well I only have the length of the message to go
on. If I use the starting characters "ABCD" as the EOL, the last
message in will not get processed until another. This is to be
expected. I could count the number of characters until the message
length, copy out the message, but would then have to shift the entire
buffer to the left in case part of another message was in the previous
transmission. Or is there a natural break so that one event can not
have two separate partial TCP packets? I know that this is probably a
3rd party question.
What is a good way to deal with something like this?
Thanks,
Tom