Recently I started implementing a GMP to GTP adapter. This is tricky, since GMP is asynchronous. For example, I implemented the "genmove" GTP command so, that if no GMP command has arrived, the adapter waits until a move arrives. However, if the other side sends no move, the adapter would wait forever or at least a long time, since a timeout would have to be set to a very high value, because you don't really know how long the opponent could take for a move. So there again is a big need to make genmove interruptible.
After trying to implement the "abort" command (as suggested in earlier postings on this list) on a server as well as a client side, I am more convinced than before, that my first idea is better.
The abort command is inherently asynchronous (potentially overlapping with another command), whereas the regular GTP command stream is synchronous. So it is not very convenient to see abort as a regular command.
If you do so, things become unnessesarily complicated on the server side. The read thread needs to remember all abort commands received while a regular command was processed to be able to answer them correctly after printing the answer of the regular command.
Same on the client side, e.g. a graphical user interface which sends an abort command if the use presses a stop button needs to remember that, to be able to collect the responses. This makes conventional serialization technics with a read thread and event based GUIs not work and the code becomes really messy.
Also, what should the program do with a failure response? The response to it will be received after the response to the regular command anyway?
So IMO an abort command should not be seen as a regular command and should *not* need a response.
It is not very important whether the abort command is a word or a character. The only advantage of a character is, that if you take a control character not used by GTP, you could make interruption an optional extension to GTP that is simply ignored by clients that don't know it (from the GTP specs: clients must discard control characters not used by GTP).
- Markus