Author: Robert Hyatt
Date: 13:38:20 09/01/04
Go up one level in this thread
On September 01, 2004 at 16:16:58, Dieter Buerssner wrote: >On August 30, 2004 at 19:51:17, Robert Hyatt wrote: > >>On August 30, 2004 at 18:39:58, Dieter Buerssner wrote: >> >>>On August 30, 2004 at 15:39:45, Robert Hyatt wrote: >>> >>>>On August 30, 2004 at 14:40:25, Uri Blass wrote: >>>> >>>>>/* When using Standard C input functions, also check if there >>>>>is anything in the buffer. After a call to such functions, >>>>>the input waiting in the pipe will be copied to the buffer, >>>>>and the call to PeekNamedPipe can indicate no input available. >>>>>Setting stdin to unbuffered was not enough, IIRC */ >>>>>//input_init(); >>>>> if (stdin->_cnt > 0) >>>>> return 1; >>>>That will not work reliably. If you run with winboard/xboard long enough it is >>>>guaranteed to hang for the reason I gave. PeekNamedPipe will not see input that >>>>has already been read by the C library and tucked away in a library buffer. >>> >>>It seems to work very reliably for me. See the above comment in the code (I >>>actually wrote that comment ...). >>> >>>Under Unix, setting stdin to non-buffered by the Standard C function setvbuf >>>and using select seems to work reliably, too. I read all the input with the >>>Standard C FILE * interface. > >>Yes. _if_ you disable buffering. But it seems that Uri has not, and has been >>simply lucky... > >No. You don't need to disable buffering under Windows with the code Uri has >posted. Read the comment/code again. It checks the internal buffer state. > >Uri's only problem seems to be, that that code is too slow to call it at every >node. > >Regards, >Dieter Maybe I am overlooking something? I assume stdin->_cnt is the _system_ buffer stuff? If it is, it is the wrong count for the reason I have already given, the C library generally uses read() to suck stuff out of the system buffer, and read() goes past EOL and reads _everything_ in the system buffer up to the number of bytes specified in the read() call... Maybe I don't understand the stdin->_cnt stuff in windows of course....
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.