I am trying to learn how to do Named Pipes. So I created a Server and Client in LinqPad.
Here is my Server:
var p = new NamedPipeServerStream("test3", PipeDirection.Out);
p.WaitForConnection();
Console.WriteLine("Connected!");
new StreamWriter(p).WriteLine("Hello!");
p.Flush();
p.WaitForPipeDrain();
p.Close();
Here is my Client:
var p = new NamedPipeClientStream(".", "test3", PipeDirection.In);
p.Connect();
var s = new StreamReader(p).ReadLine();
Console.Write("Message: " + s);
p.Close();
I run the server, and then the client, and I see "Connected!" appear on the server so it is connecting properly. However, the Client always displays Message:
with nothing after it, so the data isn't actually travelling from server to client to be displayed. I have already tried swapping pipe directions and having the client send data to the server with the same result.
Why isn't the data being printed out in the screen in this example? What am I missing?
Thanks!