I'm trying to learn how to make named pipes. Therefore, 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 start the server and then the client, and I see "Connected!". appear on the server, so it connects correctly. However, the client always displays Message:without anything after it, so the data does not actually go from the server to the client for display. I already tried to recode the directions of the pipelines and send the client data to the server with the same result.
Why is this screen not printing data? What am I missing?
Thank!
source
share