using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.IO.Pipes; using System.Threading; namespace PipeServerCommunication { class Reader { private NamedPipeServerStream pipeIn; private StreamReader sr; public Reader() { pipeIn = new NamedPipeServerStream("testpipe", PipeDirection.In); Console.WriteLine("Waiting for client to connect"); if (pipeIn!=null) pipeIn.WaitForConnection(); Console.WriteLine("Client connected."); sr = new StreamReader(pipeIn); } public void Read() { while (true) { try { String s=sr.ReadLine(); Console.WriteLine(s); } catch (IOException e) { } } } } class PipeServerCommunicationTest { static void Main(string[] args) { Reader r = new Reader(); Thread readThread = new Thread(new ThreadStart(r.Read)); readThread.Start(); } } }