Paul Pogonyshev <[EMAIL PROTECTED]> 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.) dd -- Dave Denholm <[EMAIL PROTECTED]> http://www.esmertec.com _______________________________________________ gnugo-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnugo-devel

