Hi, I'm trying to write a dart application that can talk to a standalone process on my server, I need to be able to both read and write to that process.
The dartlang web site shows a nice example of how to get output from a process here:
However, this example does not show how to write data to the process' stdin.
Here is my broken, non-working code:
void main() {
var p = Process.start('/usr/local/bin/stockfish', []);
var stdoutStream = new StringInputStream(p.stdout);
stdoutStream.onLine = () => print(stdoutStream.readLine());
p.stdin.writeString("exit\n", Encoding.ASCII); // SocketIOException: writeList failed - invalid socket handle
p.onExit = (exitCode) {
print('exit code: $exitCode');
p.close();
};
}
Please help. Am I doing this wrong? How do I send a command to a process that takes commands from stdin?