Author: Severi Salminen
Date: 16:37:44 11/04/02
Go up one level in this thread
>>I try to get the WinBoard interface working without disabling input buffering. >>Disabling the buffer by setbuf(stdin, NULL) causes problems with WB. But I have >>also a problem _without_ disabling the buffer: >> >>These are send to engine: >> >>7360 >first : time 5794 >>otim 5935 >>7360 >first : usermove 7360 >first : g1f3 >> >>PeekNamedPipe reports 34 bytes in pipe. After 1st fget() I get only the first >>command (time 5694) but after that PeekNamedPipe tells that 0 bytes available in >>pipe. When doing a fget() after this I can, however, read the next command. So, >>the question: how can I fetch these commands so that PeekNamedPipe doesn't get >>confused -> after first fget(), PeeknamedPipe should give 24 bytes available, >>not 0. fget clearly is not the right function, but others seem to behave >>identically. >> >>Severi > >If you don't disable buffering, it simply won't work correctly. You need to be >able to >ask the question "is there any unread input that I need to process?" You can >only do this >at the system level, checking on system buffers. Unfortunately, when you do a >buffered >I/O read, the C library reads in _everything_ in the system buffer, and gives >the first piece >of it to you. If you ask "is there more input" the answer is "no" because the >system buffer >is empty. you get way out of sync with things. If you do another read, you >will get the >next piece of data, but if there is none, you block, which you don't want to do. > >You have two choices: > >(1) disable buffering or else use unbuffered I/O (read/write). I do the latter >and it works >perfectly; > >(2) use a separate I/O thread so that blocking waiting on input is perfectly OK, >since the >engine thread can continue to execute as it should.... Ok, thanks for answer. Requiem actually used to work like that but then I noticed a strange bug. When I copied a pgn game from somewhere and pasted it to WB and then pressed the down arrow, WB crashed and didn't respond to anything. And debug file ended in the middle of WB sending "usermove MOVE" to Requiem. If I copied a shorter pgn it didn't crash. Enabling buffering made the problem go away but I got other problems. I also noticed that Crafty hangs also if you press up and down arrows fast. (Not that this is something a "ordinary user" would do, but still...). Well, maybe I should disable the buffering and try to see how to get rid of the problem. Are you using _read and _write from stdio.h or what? Severi
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.