[Top][All Lists]

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

Re: [gnugo-devel] GTP sometimes fails

From: Paul Pogonyshev
Subject: Re: [gnugo-devel] GTP sometimes fails
Date: Fri, 18 Mar 2005 21:09:04 +0200
User-agent: KMail/1.4.3

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?
> My send_command() is shown below.
> I'm wondering if when fgets() returns NULL if it means Gnugo is still
> processing? Should I just do a continue to have it try again? Perhaps
> combined with sleeping for a millisecond or something. Or should fgets()
> wait forever until the remote program sends a carriage-return?

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...

You may want to look at Quarry's ( way of
handling GTP.  It can be used asynchronously and the main program does
it that way.  The simple test in `src/gtp/gtp-test.c' demonstrates
setting up the pipes, connecting to an engine and printing basic info.
The client code is in `src/gtp/gtp-client.c'.


reply via email to

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