Gunnar Farnebäck gunnar@lysator.liu.se writes:
Phil wrote:
In the specification, the end-of-line will be either a linefeed or carriage return. Empty lines are to be disregard and no output will be sent back.
What about lines containing only whitespace ? Are they considered empty, and so not echo-ed, or are they echo-ed ?
I have one small niggling concern with this... It sees we wish to allow controlling programs to be lax about how they terminate lines. ie the controller is not required to know exactly what it's sending.
However, because the protocol is a request-response protocol, it is vital that both sides know whether a response is expected. If the controller thinks a response is required, but the engine doesn't, then it could deadlock. Being woolley about line termination could possibly result in such a situation.
I suspect the current proposal is safe, but it's something to bear in mind...
dd
Dave wrote:
What about lines containing only whitespace ? Are they considered empty, and so not echo-ed, or are they echo-ed ?
If the controller sends an empty line (or one which contains only a comment, which should be considered no different) the engine should not respond. A well behaved controller should never send a non-empty line with only whitespace, but if the engine does receive one it should not respond. Notice that CR should be discarded on input and does not qualify as whitespace.
However, because the protocol is a request-response protocol, it is vital that both sides know whether a response is expected. If the controller thinks a response is required, but the engine doesn't, then it could deadlock. Being woolley about line termination could possibly result in such a situation.
Absolutely true, which I noticed when debugging gnugoclient. One problem that can be expected to be common is that an engine happens to finish its response with three (or more) rather than two consecutive newlines. This is an error by the engine that the controller can easily detect and ignore. In other words the principle here is that a well behaved engine should not send stray newlines, but should they appear the controller should ignore them. The opposite problem of an engine failing to properly finish its response with two newlines WILL deadlock. Just don't do this mistake.
/Gunnar