Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Winboard problem solved ?!

Author: Tony Werten

Date: 03:18:03 08/24/03

Go up one level in this thread


On August 23, 2003 at 18:31:00, Tony Werten wrote:

>On August 23, 2003 at 10:36:35, Dieter Buerssner wrote:
>
>>On August 23, 2003 at 09:17:45, Tony Werten wrote:
>>
>>>On August 22, 2003 at 20:40:06, Dann Corbit wrote:
>>>
>>>>In C or C++, you need to turn ALL buffering OFF for standard in put and output.
>>>>
>>>>In C:
>>>>setbuf(stdout, NULL);
>>>>setbuf(stdin, NULL);
>>>>setvbuf(stdout, NULL, _IONBF, 0);
>>>>setvbuf(stdin, NULL, _IONBF, 0);
>>>>
>>>>In C++:
>>>>cout.rdbuf()->setbuf(NULL,0);
>>>>cin.rdbuf()->setbuf(NULL,0);
>>>>
>>>>Probably, that is the problem.  I imagine that there is a way to turn off
>>>>buffering completely in Delphi, but I am not terribly familiar with the
>>>>language.
>>>
>>>This makes sense also because I started to have more problems when I started to
>>>write more.
>>
>>I don't need to set stdout to unbuffered mode (I do need it for stdin). I also
>>cannot see, why it should be needed. At points, where the engine wants, that the
>>GUI sees what is written, it can (and must, if not set to unbuffered) flush
>>stdout.
>>
>>It seems somehow, that writeln tries more than C streams. Perhaps it even closes
>>and reopens the output handle in some situation behind the scenes?
>
>You seem to be correct.
>
>Andreas Herrmann gave me some code that flushes after every character written (
>so not using writeln but just write) that seems to work correctly.
>
>So, a flush after every character, lots of more flushes, and it seems to be
>working correct. It looks like the problem wasn't in the flush but in the
>writeln.

I let it run for 12 hours and it worked witout problems.

There are 2 differences between the "writeln" and the "write" way.

With write, you send about 20 times as much flushes, but they don't seem to
matter.

With writeln, you (automaticly) send a #13#10 after each string, with write, (by
hand) only a #10 ( don't know if that's the CR or the LF) After a couple of
hunderds of them, the #13 seem to give problems.

Or at least that's what sounds logical to me. I should get a real hobby.

Tony

>
>Tony
>
>>
>>Are you sure, that the "exited unexpectadly" comes from the output pipe of the
>>engine? I just browsed very fast over WB source. I don't understand much of it,
>>but it seems to come from the input pipe of the engine.
>>
>>Regards,
>>Dieter



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.