[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] GTP sometimes fails

From: Dave Denholm
Subject: Re: [gnugo-devel] GTP sometimes fails
Date: Sat, 19 Mar 2005 18:19:17 +0000
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (usg-unix-v)

Paul Pogonyshev <address@hidden> writes:

> Darren Cook wrote:
>> Hi,
>> I'm connecting to gnugo 3.6 using GTP: using pipes from C++. When
>> running my unit tests, they sometimes work fine, but sometimes they
>> fail. If it fails it seems to be on the first command I send after
>> successfully connecting.
>> I was originally using lower-level file descriptors, but after having
>> lots of problems, I looked at gnugo's oracle.c code and switched to
>> using two FILE*. So my code is now basically the same as oracle.c
>> (except I use fwrite instead of fprintf). Does anyone have similar
>> problems with that code?

> No, fgets() is synchronous.  If it returns NULL, then your pipe has
> passed out already.
> I cannot really read your code, but it seems correct.  I can think of
> two possible problems: bad pipe setup or too small `readbuf'.  If you
> send `list_commands', two kilobytes might be not enough...

Don't know if anyone's already suggested this, but I find
truss (strace on linux, I think) very useful for tracking down
this kind of problem : you can see the system calls (and hence i/o
requests) both ends are making, in the order they happen.

(FWIW I'd have stuck with lower-level file descriptions, since
stdio just adds more places for things to go wrong with buffering,
blocking reads when you didn't want it to, etc.)

Dave Denholm              <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]