krona-staff/test_pipe.cs

26 lines
1,003 B
C#

using System;
using System.IO.Pipes;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var server = new NamedPipeServerStream("global\\testpipe", PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
var _ = server.WaitForConnectionAsync();
var client = new NamedPipeClientStream(".", "testpipe", PipeDirection.InOut, PipeOptions.Asynchronous);
try {
await client.ConnectAsync(1000);
Console.WriteLine("Connected with testpipe!");
} catch {
Console.WriteLine("Failed to connect with testpipe!");
}
var client2 = new NamedPipeClientStream(".", "global\\testpipe", PipeDirection.InOut, PipeOptions.Asynchronous);
try {
await client2.ConnectAsync(1000);
Console.WriteLine("Connected with global\\testpipe!");
} catch {
Console.WriteLine("Failed to connect with global\\testpipe!");
}
}
}