06-18-2007 02:02 AM
06-18-2007 02:33 AM
06-18-2007 04:48 AM
To expand on the explanation which was given - the TCP functions do not have something like the termination character you would find in the serial function, so you have to know how many bytes to read in advance.
To do this, a simple mechanism is used - before data is sent, the length of the string is checked (this produces an I32 number, which is 4 bytes) and that length is sent before the actual data. On the receiving side, you always know to check for that length first and you use the result to know how many bytes to read.
Other implementations might include reading a fixed number of bytes and relying on timeout errors or reading one byte at a time until you find a termination character, but this method is usually better.