Louis J Scoras wrote:
On 11/2/06, Paul L. [email protected] wrote:
You mean, line by line? The socket class you are describing doesn’t know
about lines, it knows about blocks.
Nope. Not line by line. All the parser should need is a token, and I
should only have to read as much data as I need to complete one, so
blocks would be fine.
And you could set things up to read more data when your block-oriented
stream is depleted, easy to arrange. This will provide the appearance of
local stream, a common arrangement in socket reading algorithms.
So try this: read a block, split it into lines, do your processing. If
you do this, you will discover some blocks end in the middle of a line.
Then you will say, “Gee, maybe I should read the whole thing, then do the
No, I wouldn’t say that I’d just read enough segments into a
buffer until I could complete the next token.
Yep. Read the entire thing. Then process the result.
Why? I should be able to start processing simultaneously.
Block by block, yes. The block reading back end can be made to appear to
a stream locally, but there are excellent reasons to read blocks at the
network-protocol level, and sometimes the bigger the better.
what the stream paradigm was developed for.
Yes. You can always turn a block into a stream locally. And no, you
have to read the entire thing, I just prefer it that way. A personal
preference, nothing more, doubtless springing from my unreliable