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

Re: [computer-go] GTP and Tourney in SmartGo 1.4



Persson, Magnus wrote:
> [...]
> 
> You need to make it clear how to do it in Windows. It took me perhaps 6
> hours of experimentation and searching for information about pipe
> programming and a mix of bad and good luck before I even saw some hope
> of transferring a single byte between two programs. I might be unusually
> incompetent as a programmer, but I do others could repeat exactly the
> same errors as I did.

Disclaimer: I abandoned Windows 1.5 years ago and don't really
remember how to program for it.

First about engine side, assuming pipe has been created.  Have you
tried to connect some trivialty like C code below to kgsGTP?

#include <stdio.h>

int
main(int argc, char *argv[])
{
  char buffer[1000];

  while (fgets(buffer, 1000, stdin))
    fputs(buffer, stderr);

  return 0;
}

I don't know Delphi, but in standard Pascal that would be something
like readln()/writeln() instead of fgets()/fputs().  If you are unable
to see stderr in the first place, try to pop up some message box
instead.

This way it can be easily seen if kgsGTP manages to create pipes at
all.  If it prints at least a single line to stdout, then we got
something from the controller.

I briefly looked through GLib's code (http://gtk.org/) for spawning
processes under Windows with piped `stdin', `stdout' and `stderr'.
It uses functions with names similar to those on UNIX-like system:
pipe() to create a pipe, spawnvp() to launch a process (not exec*()),
dup2() to duplicate file descriptor etc.  So yes, it is possible to
create "normal" pipes under Windows.  However, there seems to be a
trick with creating "intermediate" child, because under Windows
processes "run away" (i.e. you cannot execute your program's code
in a spawned process).

Paul
_______________________________________________
computer-go mailing list
computer-go@xxxxxxxxxxxxxxxxx
http://computer-go.org/mailman/listinfo/computer-go