From: Paul Lutus Date: 2006-11-03T07:05:15+09:00 Subject: Re: net/http and rexml Louis J Scoras wrote: > On 11/2/06, Paul Lutus 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 input stream is depleted, easy to arrange. This will provide the appearance of a 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 >> processing." > > No, I wouldn't say that ;) I'd just read enough segments into a > buffer until I could complete the next token. s/segments/blocks/ > >> >> 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 be a stream locally, but there are excellent reasons to read blocks at the network-protocol level, and sometimes the bigger the better. > That's > what the stream paradigm was developed for. Yes. You can always turn a block into a stream locally. And no, you don't have to read the entire thing, I just prefer it that way. A personal preference, nothing more, doubtless springing from my unreliable Internet access. -- Paul Lutus http://www.arachnoid.com