Use asynchronous communications, not synchronous. Read the developers guide.
Perform the read in the ondata event which fires with async communications when there is input data. Accumulate the data read on successive invocations data+=socket.read(). While the data buffer contains a CR Char 13), remove all the chars in the data buffer up to and including the CR as that is what you want and process them as the message. Leave what was in the buffer after the CR (if there was anything) as the start of the next message. When the data buffer contains no CR, exit the ondata function
Last edited by Barry Gordon on October 26, 2009 14:36.