> smaller for larger boards. The only part of our program that is not > strictly ANSI C++ compliant is is_there_input(), ... > ... > return select(1,&read,&write,&except,&timeout); > ... > If you are interested on a Windows equivalent, I might be able to > provide one.
Hi Alvaro, I'm interested in a windows equivalent, though for a program nothing to do with computer go. Basically select() on windows does not work for stdin (it only works for sockets created with winsock). The code I found to use is: DWORD stdin_timeout=100; //In milliseconds, so sleep for 0.1s. HANDLE stdin_handle=GetStdHandle(STD_INPUT_HANDLE); DWORD stdin_wait_result=WaitForSingleObject(stdin_handle,stdin_timeout); if(stdin_wait_result==WAIT_OBJECT_0){ //There is input on stdin } else{ //Stdin is quiet } (For a pondering go program you want stdin_timeout set to 0.) However, I suspect this code is actually blocking (sometimes?). In addition behaviour seems to be different in each of: * Using it from the console * Using it where stdin is connected to a pipe (also see [1]) * Using it under cygwin, over ssh. Most of what google has turned up for me so far is that if you want to reliably read from stdin in a non-blocking way you should use threads. Like you, this is a path I don't want to go down, especially as select(stdin) works fine on linux, but it is looking like I have no choice. Darren [1]: http://communicator.sourceforge.net/sites/MITRE/distributions/GalaxyCommunicator/contrib/MITRE/utilities/src/stdin_utility.c _______________________________________________ computer-go mailing list computer-go@computer-go.org http://www.computer-go.org/mailman/listinfo/computer-go/