I know I've asked variations on this question before, but I keep cheating the answer by using the "to count" option with a known number of bytes. Thus far, I've been able to structure everything to always be the same number of bytes received (the current version uses 30 bytes) so I can just always use:
- Code: Select all
wait for data from source connectionName to count 30
Now, however, I can no longer use that crutch, as I have data coming which I cannot make other than 12 bytes.
So.
I want to be able to read an arbitrary amount of bytes, stopping after there are no more bytes to read. To that end, I have the following questions:
1. Is a wait statement even needed? Could I replace it with a loop? Something like
- Code: Select all
do
read byte from source connectionName to count 1
stick that byte somewhere
loop until no more bytes
How do I tell if there are no more bytes to read?
2. If that doesn't work, then using no "to count" on the wait for data, will read one byte, yes? So I could do that loop above with a Wait and a Read, looping until there is no more data. But same question, how do I tell there is no more data to read?
3. Finally, if there is no way to tell no data is left, can I do:
- Code: Select all
wait for 12 bytes
check to see if this fits the 12 byte data style
if yes, goto TwelveByteData
if no, wait for 18 more bytes
do the ThirtyByteData stuff
Will the 18 bytes be "lost" if no one is waiting for them?
Thanks for all the help. I promise I'll have something cool to show from all of this, one day!
Brian