So in my program, I am reading a series of ASCII strings from the
TCPSocket. My code is letting everything through just fine. The
problem is in the verification of the data. You see, the point of this
protocol I am using is I am receiving a series of strings where each
string has a 4 letter command and then parameters after it. The command
and parameters are separated by commas. So my main worry here is most
of the examples of TCPSocket networking I’ve seen use the #read method
which requires a known amount of bytes to be read and I am worried that
I will cut one of the commands part way through and cause problems.
I thought about using #readlines but I wasn’t sure how it would treat a
split message. If I get a message like
but the full last command was actually
then that messes everything up. Is there a way to read data delimited
by a newline and if the last line read does not end with a newline to
have it placed back in a buffer of some sort to get the next set of
messages appended to it?