照著課本練習
using System;
using System.IO;
using System.IO.Pipes;
namespace pipe_1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World! pipe 1");
using (NamedPipeServerStream server=new NamedPipeServerStream("demo"))
{
server.WaitForConnection();
try
{
using(StreamReader reader=new StreamReader(server))
{
string msg = null;
while((msg=reader.ReadLine())!=null)
{
Console.WriteLine($"client:{msg}");
}
}
}
catch
{
Console.WriteLine("error");
}
// Console.WriteLine(" wait exit");
// Console.Read();
}
}
}
}
沒有留言:
張貼留言