Hi,
1 2 3 4
|
string input;
do
getline(cin,input);
while (gtp_process_command(input));
|
For a program-to-program communication (GTP -
http://www.lysator.liu.se/~gunnar/gtp/) protocol I thought the above inputreader would be enough. In short all commands by the the other program (the controller) come in form of a full line, and gtp_process_command is able to process those properly. All responses from my program are full lines as well.
When doing tests on a console, this also works fine... (the program discards faulty lines, properly responds to all commands, etc)
But when I connect my program to a controller, an the controller sends multiple commands at once, my program simply ignores the 2nd command.
My guess is, that the second input line from the controller comes before my program is done processing the first line, and thus getline() somehow fails to catch the second input line...
If it is this, how to fix this problem?
If this can't be the case, and above code should under all circumstances catch all lines... well... then I at least know I have to search the bug elsewhere...
edit: of course gtp_process_command always gives back true, except the quit command was called, which wasn't the case here