Created
December 2, 2015 20:01
-
-
Save VisualMelon/f0c8adb7558fbc81b36f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace StdioComms | |
{ | |
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
if (args.Length > 0 && args[0] == "client") | |
{ | |
// client | |
string line; | |
while ((line = Console.ReadLine()) != null) | |
{ | |
Console.WriteLine(int.Parse(line) * 2); | |
} | |
} | |
else | |
{ | |
// controller | |
string line; | |
var procStart = new System.Diagnostics.ProcessStartInfo("stdioComms.exe"); | |
procStart.RedirectStandardInput = true; | |
procStart.RedirectStandardOutput = true; | |
procStart.Arguments = "client"; | |
procStart.UseShellExecute = false; | |
var proc = System.Diagnostics.Process.Start(procStart); | |
var procWriter = proc.StandardInput; | |
var procReader = proc.StandardOutput; | |
while ((line = Console.ReadLine()) != null) | |
{ | |
procWriter.WriteLine(line); | |
Console.WriteLine(procReader.ReadLine()); | |
} | |
proc.Kill(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When run, it spawns a new client process, which it then passes input to, and writes output from, synchronously. The effect is that you have a unnecessarily complicated terminal which doubles any integer you plug in.