Reading TCP data stream and finding an End of line

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

.



Relevant Pages

  • Re: problem reading TCP packets on socket
    ... the client strips down the message in the ... characters on my bufferedReader, and I start over. ... I realized that problems arised when TCP ... Using a BufferedReader as you have done improves the chances of getting a whole array in one read, but still does not ensure it. ...
    (comp.lang.java.programmer)
  • problem reading TCP packets on socket
    ... the client strips down the message in the ... characters on my bufferedReader, and I start over. ... I realized that problems arised when TCP ...
    (comp.lang.java.programmer)
  • Re: AOL passwords / crypt() and online brute forcing
    ... I don't have access to AOL to check their documentation on their ... AOL locks account after so many password attemps.. ... Take the tcp lag and application lag into account, and say you can pop 10 ... the 94 displayable ascii characters in about 26,623,381 years. ...
    (Vuln-Dev)
  • RE: AOL passwords / crypt() and online brute forcing
    ... The sad truth is that most of the passwords are less than 8 characters ... If the AOL users at least get to 8, ... AOL passwords / cryptand online brute forcing ... Take the tcp lag and application lag into account, and say you can pop 10 ...
    (Vuln-Dev)