Author: Robert Hyatt
Date: 07:32:20 07/29/99
Go up one level in this thread
On July 29, 1999 at 09:43:00, frank phillips wrote: >On July 28, 1999 at 23:20:22, Robert Hyatt wrote: > >>On July 28, 1999 at 16:16:56, Frank Phillips wrote: >> >>> >>>I had hoped that testing for input during pondering would be as simple as >>>copying the Inter()/CheckInput() code from ExChess/Crafty, but I seem to be >>>missing something. >>> >>>Everything works fine in a non-xboard mode DOS box (simple kbhit()), but my >>>program (called Searcher by the way) has stopped recognising input from >>>WinBoard. >>> >>>In xboard mode I set setbuf(stdin, NULL) and signal(SIGINT, SIG_IGN). >>> >>>Any help or hints would be greatly appreciated, although I should point out that >>>I know nothing about Pipes and so forth. >>> >>>Frank >> >> >>Simply copy the CheckInput() function from Crafty. In a dos box, kbhit() is >>ok. With winboard, you need PeekNamedPipe(). > > >Bob > >Thanks for the response, but I obviously did not express myself clearly enough. >What you suggest is exactly what I did. It worked in a DOS box but not with >WinBoard, and I wondered whether it should have worked or if there is something >else I needed to do. > >Frank The other issue is buffering. If you use buffered I/O (cin/cout/scanf/fgets/ etc...) then you have room for error. When you do a buffered I/O call, the C library uses a normal unbuffered read() to suck everything into an internal buffer. Then it gives you the first 'record' in that stuff and holds the rest in its internal buffer. Additional calls get the rest of the data, piece by piece. But when you use select() (unix) or PeekNamedPipe() (windows) that checks the system buffer to see if data is available. It doesn't know about the library buffer, so it will usually say 'no more data' even though the library has some cached away for you. Read the engine-intf.txt document in winboard. It has a good explanation of this and how to cure it (use only read() so that _you_ can do the buffering and solve the problem)...
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.