From: GDWebster <gd...@wa...> - 2002-03-15 23:17:48
|
> Thanks for putting together an NNTP client! If you're interested, there > was also some earlier prototyping of the NNTP protocol that is available > in the CVS repository. It is under the prototype directory. Ah. No more this getting-excited-and-plowing-straight in stuff for me.... > You mention one of my main complaints I have with current POP interface -- > messages are read completely before returned to the client. Initially, > the object channel returned to the client would read data on demand. > Unfortunately, if a client didn't read all of the data out of the channel, > then the protocol would be in an inconsistent state. > > To avoid this, I added a quick fix to read the entire message before > returning it. > > Here are the choices I see related to this issue: > > - API has invariants that can't be checked by the compiler (e.g. it is > an error to not cloes the channel before sending another command). A > custom in_obj_channel could be written that could fix the problem > discussed above. I think this is what I have done. This is Netnews' method for opening a channel to read a text response: method response_open_in () = if state <> `Command then raise Wrong_state (state, `Command); state <- `Receiving_text; let restore_state () = state <- `Command in new response_input_channel ic ~onclose:restore_state All NNTP command methods have the "if state <> `Command then..." assertion. Improper flow control still causes a runtime error, but all at least it happens promptly and clearly this way, before anything really puzzling is allowed to happen. "response_input_channel" objects read to the end of the current text response if they are closed before EOF, so there's no way to leave a response half read, but otherwise there is nothing special about them. -- -- Glyn Webster ~ Simplicity Himself. |