public Stream GetWriteStream() { var pipeServer = new AnonymousPipeServerStream(); var pipeClient = new AnonymousPipeClientStream(pipeServer.GetClientHandleAsString()); Task.Factory.StartNew(() => { using var sr = new StreamReader(pipeClient); using var sw = new StreamWriter(_fileStream, new UTF8Encoding(false)); sw.WriteLine(JsonConvert.SerializeObject(_header)); var buf = new char[1024]; int bytesRead; while ((bytesRead = sr.Read(buf, 0, buf.Length)) != 0) { var ts = DateTimeOffset.Now - _startTimeStamp; var chars = string.Join("", buf.Take(bytesRead).Select(c => c.ToString())); var data = new List <object> { ts.TotalSeconds, "o", chars }; sw.WriteLine(JsonConvert.SerializeObject(data)); // asciinema compatible Console.Out.Write(buf.Take(bytesRead).ToArray()); } WaitForWriter.Set(); }, TaskCreationOptions.LongRunning); return(pipeServer); }
public void StartClient(string pipeNameInput, string pipeNameOutput) { _inClient = new AnonymousPipeClientStream(PipeDirection.In, pipeNameInput); _outClient = new AnonymousPipeClientStream(PipeDirection.Out, pipeNameOutput); _readStream = new StreamString(_inClient); _writeStream = new StreamString(_outClient); }
static void Main(string[] args) { if (args.Length > 0) { using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0])) { Console.WriteLine("[CLIENT] Current TransmissionMode: {0}.", pipeClient.TransmissionMode); using (StreamReader sr = new StreamReader(pipeClient)) { // Display the read text to the console string temp; // Wait for 'sync message' from the server. do { Console.WriteLine("[CLIENT] Wait for sync..."); temp = sr.ReadLine(); }while (!temp.StartsWith("SYNC")); // Read the server data and echo to the console. while ((temp = sr.ReadLine()) != null) { Console.WriteLine("[CLIENT] Echo: " + temp); } } } } Console.Write("[CLIENT] Press Enter to continue..."); Console.ReadLine(); }
void CreateClientPipes() { string[] inHandles, outHandles; invoker.GetClientPipeHandles(out inHandles, out outHandles); Assert.That(inHandles, Is.Not.Null); Assert.That(outHandles, Is.Not.Null); Assert.That(inHandles.Length, Is.EqualTo(NUM_PIPE_PAIRS)); Assert.That(outHandles.Length, Is.EqualTo(NUM_PIPE_PAIRS)); for (int n = 0; n < NUM_PIPE_PAIRS; ++n) { // Create NON-OWNED safe handles here. Passing in the pipe handle string into the // constructor of AnonymousPipeClientStream would create an owned handle, which // would mess up the ref count and cause double-deletion because both client*Pipes // and the invoker's pipe streams both assume they own the pipe. var outHandle = new SafePipeHandle(new IntPtr(long.Parse(outHandles[n])), false); var inHandle = new SafePipeHandle(new IntPtr(long.Parse(inHandles[n])), false); // Note: The server's in pipes are the client's out pipes and vice versa. clientInPipes[n] = new AnonymousPipeClientStream(PipeDirection.In, outHandle); clientOutPipes[n] = new AnonymousPipeClientStream(PipeDirection.Out, inHandle); } }
public static void ClientSendsByteServerReceives() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.In)) { Assert.True(server.IsConnected); server.ReadMode = PipeTransmissionMode.Byte; using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { Assert.True(server.IsConnected); Assert.True(client.IsConnected); client.ReadMode = PipeTransmissionMode.Byte; byte[] sent = new byte[] { 123 }; byte[] received = new byte[] { 0 }; client.Write(sent, 0, 1); server.DisposeLocalCopyOfClientHandle(); Assert.Equal(1, server.Read(received, 0, 1)); Assert.Equal(sent[0], received[0]); } // not sure why the following isn't thrown because pipe is broken //Assert.Throws<System.IO.IOException>(() => server.ReadByte()); } }
public static void Linux_BufferSizeRoundtrips() { // On Linux, setting the buffer size of the server will also set the buffer size of the // client, regardless of the direction of the flow int desiredBufferSize; using (var server = new AnonymousPipeServerStream(PipeDirection.Out)) { desiredBufferSize = server.OutBufferSize * 2; Assert.True(desiredBufferSize > 0); } using (var server = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.None, desiredBufferSize)) using (var client = new AnonymousPipeClientStream(PipeDirection.In, server.ClientSafePipeHandle)) { Assert.Equal(desiredBufferSize, server.OutBufferSize); Assert.Equal(desiredBufferSize, client.InBufferSize); } using (var server = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.None, desiredBufferSize)) using (var client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { Assert.Equal(desiredBufferSize, server.InBufferSize); Assert.Equal(desiredBufferSize, client.OutBufferSize); } }
static void Main(string[] args) { using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0])) { using (StreamReader sr = new StreamReader(pipeClient)) { String temp = null; Console.WriteLine("[client] wait for sync ..."); do { temp = sr.ReadLine(); } while (!temp.StartsWith("SYNC")); Console.WriteLine("client in"); while ((temp = sr.ReadLine()) != null) { Console.WriteLine("[client] receive message: " + temp); if (temp == "exit") { break; } } } Console.Write("[client] Press Enter to exist..."); Console.ReadLine(); } }
protected static void StartClient(PipeDirection direction, SafePipeHandle clientPipeHandle) { using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(direction, clientPipeHandle)) { DoStreamOperations(client); } }
public void Run() { Task.Factory.StartNew(() => { if (_keeper == null || string.IsNullOrWhiteSpace(_comHandle)) { return; } try { using var client = new AnonymousPipeClientStream(PipeDirection.In, _comHandle); using var reader = new BinaryReader(client); while (_keeper != null) { var data = reader.ReadString(); switch (data) { case "Kill-Node": _logger.Information("Reciving Killing Notification"); _system.Terminate(); _keeper = null; break; } } } catch (Exception e) { _logger.Error(e, "Error on Setup Service kill Watch"); } }, TaskCreationOptions.LongRunning); }
private static void Pipes_WaitForReadThenTryReadValues() { using (AnonymousPipeServerStream serverPipe = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream clientPipe = new AnonymousPipeClientStream(PipeDirection.In, serverPipe.ClientSafePipeHandle)) { IWritableChannel <int> writer = Channel.WriteToStream <int>(serverPipe); IReadableChannel <int> reader = Channel.ReadFromStream <int>(clientPipe); Task.WaitAll( Task.Run(async() => { for (int i = 0; i < 100; i++) { await writer.WriteAsync(i); } writer.Complete(); Assert.False(writer.TryWrite(100)); }), Task.Run(async() => { int result; int i = 0; while (await reader.WaitToReadAsync()) { if (reader.TryRead(out result)) { Assert.Equal(i++, result); } } Assert.False(reader.TryRead(out result)); })); } }
static void Main(string[] args) { if (args.Length > 0) { using (PipeStream pipeClient = new AnonymousPipeClientStream(args[0])) { Console.WriteLine("Current TransmissionMode: {0}.", pipeClient.TransmissionMode); // Anonymous Pipes do not support Message mode. try { Console.WriteLine("Setting ReadMode to \"Message\"."); pipeClient.ReadMode = PipeTransmissionMode.Message; } catch (NotSupportedException e) { Console.WriteLine("EXCEPTION: {0}", e.Message); } using (StreamReader sr = new StreamReader(pipeClient)) { // Display the read text to the console string temp; while ((temp = sr.ReadLine()) != null) { Console.WriteLine(temp); } } } } Console.Write("Press Enter to continue..."); Console.ReadLine(); }
public static void ClientPipeDirectionThrows() { Assert.Throws <NotSupportedException>(delegate { AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.InOut, "123"); }); }
public static void ClientPipeHandleStringAsNotValidThrows() { Assert.Throws <ArgumentException>(delegate { AnonymousPipeClientStream client = new AnonymousPipeClientStream("-1"); }); }
public static void ClientPipeHandleAsNullThrows() { Assert.Throws <ArgumentNullException>(delegate { AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, (SafePipeHandle)null); }); }
public void ClientClosesPipe_ServerReceivesEof() { using (var pipe = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable)) using (var remote = RemoteExecutor.Invoke(new Action <string>(ChildFunc), pipe.GetClientHandleAsString(), new RemoteInvokeOptions { CheckExitCode = false })) { pipe.DisposeLocalCopyOfClientHandle(); for (int i = 1; i <= 5; i++) { Assert.Equal(i, pipe.ReadByte()); } Assert.Equal(-1, pipe.ReadByte()); remote.Process.Kill(); } void ChildFunc(string clientHandle) { using (var pipe = new AnonymousPipeClientStream(PipeDirection.Out, clientHandle)) { pipe.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5); } Thread.CurrentThread.Join(); } }
/// <summary> /// Der Einsprungpunkt für einen <i>Card Server</i>. Die Befehlszeilenparameter beschreiben /// die Kommunikationskanäle zum steuernden Client. /// </summary> /// <param name="args">Befehlsparameter für die Kommunikation.</param> public static void Main(string[] args) { // Be safe try { // Always use the configured language UserProfile.ApplyLanguage(); // Set priority Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; // Open the communication channels and attach to the pipe server using (AnonymousPipeClientStream reader = new AnonymousPipeClientStream(PipeDirection.In, args[0])) using (AnonymousPipeClientStream writer = new AnonymousPipeClientStream(PipeDirection.Out, args[1])) using (ServerImplementation server = ServerImplementation.CreateInMemory()) for (Request request; null != (request = Request.ReceiveRequest(reader));) { // Process it Response response = request.Execute(server); // Send the response response.SendResponse(writer); } } catch (Exception e) { // Report error Logging.Log(EventLogEntryType.Error, e.ToString()); } }
private static void Pipes_EnumerateValues() { using (AnonymousPipeServerStream serverPipe = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream clientPipe = new AnonymousPipeClientStream(PipeDirection.In, serverPipe.ClientSafePipeHandle)) { IWritableChannel <int> writer = Channel.WriteToStream <int>(serverPipe); IReadableChannel <int> reader = Channel.ReadFromStream <int>(clientPipe); Task.WaitAll( Task.Run(async() => { for (int i = 0; i < 100; i++) { await writer.WriteAsync(i); } writer.Complete(); Assert.False(writer.TryWrite(100)); }), Task.Run(async() => { int i = 0; IAsyncEnumerator <int> e = reader.GetAsyncEnumerator(); while (await e.MoveNextAsync()) { Assert.Equal(i++, e.Current); } })); } }
public void SetupScanListener(string pipeHandle) { Task t = Task.Run(() => { using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipeHandle)) { using (StreamReader sr = new StreamReader(pipeClient)) { while (true) { string temp; do { Console.WriteLine("[CLIENT] Wait for sync..."); temp = sr.ReadLine(); }while (!temp.StartsWith("SYNC")); while ((temp = sr.ReadLine()) != null) { Scan(temp); } } } } }); }
private static async Task Pipes_ReadWriteValues <T>(bool firstWaitToRead, int numItems, Func <int, T> getValue) { using (AnonymousPipeServerStream serverPipe = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream clientPipe = new AnonymousPipeClientStream(PipeDirection.In, serverPipe.ClientSafePipeHandle)) { IWritableChannel <T> writer = Channel.WriteToStream <T>(serverPipe); IReadableChannel <T> reader = Channel.ReadFromStream <T>(clientPipe); for (int i = 0; i < numItems; i++) { T itemToWrite = getValue(i); Task <T> readItem = firstWaitToRead ? reader.WaitToReadAsync().ContinueWith(_ => reader.ReadAsync().AsTask()).Unwrap() : reader.ReadAsync().AsTask(); Task writeItem = writer.WriteAsync(itemToWrite); await Task.WhenAll(readItem, writeItem); Assert.Equal(itemToWrite, readItem.Result); } writer.Complete(); Assert.False(await reader.WaitToReadAsync()); await reader.Completion; } }
static void Main(string[] args) { if (args.Length != 1) { return; } using (var pipeClient = new AnonymousPipeClientStream( PipeDirection.In, args[0])) { Console.WriteLine("[CLIENT] Current TransmissionMode: {0}.", pipeClient.TransmissionMode); using (var streamReader = new StreamReader(pipeClient)) { string message; do { Console.WriteLine("[CLIENT] Wait for SYNC..."); message = streamReader.ReadLine(); }while (!message.StartsWith("SYNC")); while ((message = streamReader.ReadLine()) != null) { Console.WriteLine("[CLIENT] Echo: {0}", message); } } } Console.Write("[CLIENT] Press Enter to continue..."); Console.ReadLine(); }
/// <summary> /// Record stdin /// </summary> /// <returns></returns> public Stream GetInputStream() { var pipeServer = new AnonymousPipeServerStream(); var pipeClient = new AnonymousPipeClientStream(pipeServer.GetClientHandleAsString()); return(pipeClient); }
Semaphore pipe_sem = new Semaphore(1, 1); //Sémaphore de blocage d'écriture dans le pipe vers transport //Constructeur de la couche Réseau public EntiteReseau(AnonymousPipeClientStream _reseauIn, AnonymousPipeServerStream _reseauOut) { liaison = new Liaison(); reseauIn = _reseauIn; reseauOut = _reseauOut; connexions = new ListeConnexionsReseau(); }
public static void ClientPipeHandleStringAsNullThrows() { Assert.Throws <ArgumentNullException>(delegate { AnonymousPipeClientStream client = new AnonymousPipeClientStream(null); }); }
public static void StartModule() { var args = Environment.GetCommandLineArgs(); if (args.Length >= 2) { //MessageBox.Show("ARGUMENTS RETRIEVED"); _moduleWritePipeHandle = args[1]; _moduleReadPipeHandle = args[2]; } /*else * { * MessageBox.Show("INSUFFICIENT ARGUMENTS"); * } * foreach (string s in args) * MessageBox.Show(s, "ARGUMENT");*/ _moduleReadPipe = new AnonymousPipeClientStream(PipeDirection.In, _moduleReadPipeHandle); _moduleWritePipe = new AnonymousPipeClientStream(PipeDirection.Out, _moduleWritePipeHandle); _writer = new StreamWriter(_moduleWritePipe) { AutoFlush = true }; }
void run() { try { sem = Semaphore.OpenExisting("semof"); } catch (WaitHandleCannotBeOpenedException) { Invoke(new Action(() => this.Text = "Memory-mapped file does not exist. Run Process A first.")); } using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0])) { using (StreamReader sr = new StreamReader(pipeClient)) { string temp; do { temp = sr.ReadLine(); }while (!temp.StartsWith("SYNC")); while (true) { sem.WaitOne(); while ((temp = sr.ReadLine()) != null) { int x = Convert.ToInt32(temp); int y = Convert.ToInt32(sr.ReadLine()); Invoke(new Action(() => this.Text = (x.ToString() + ";" + y.ToString()))); Invoke(new Action(() => this.Paint(x, y))); } } } } }
public DelayedBufferStream(EventHandler <byte[]> onMessage) { OnMessage = onMessage; _pipeServer = new AnonymousPipeServerStream(PipeDirection.Out); _pipeClient = new AnonymousPipeClientStream(PipeDirection.In, _pipeServer.ClientSafePipeHandle); _queue = new Queue <byte[]>(); _lastWriteTime = DateTime.Now; Task.Factory.StartNew(() => { while (!_closed) { lock (_queue) { if ((DateTime.Now - _lastWriteTime).TotalMilliseconds < 100 || _queue.Count == 0) { continue; } // merge spans var bytes = new byte[_queue.Sum(array => array.Length)]; var span = new Span <byte>(bytes); var position = 0; foreach (var array in _queue) { array.CopyTo(span[position..]); position += array.Length; }
protected override void SetIO() { parentOutputPipe = new AnonymousPipeClientStream(PipeDirection.In, parentOutputHandle); parentInputPipe = new AnonymousPipeClientStream(PipeDirection.Out, parentInputHandle); io.Input = parentOutputPipe; io.Output = parentInputPipe; }
public void ServerClosesPipe_ClientReceivesEof() { using (var pipe = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable)) using (var remote = RemoteExecutor.Invoke(new Action <string>(ChildFunc), pipe.GetClientHandleAsString())) { pipe.DisposeLocalCopyOfClientHandle(); pipe.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5); pipe.Dispose(); Assert.True(remote.Process.WaitForExit(30_000)); } void ChildFunc(string clientHandle) { using (var pipe = new AnonymousPipeClientStream(PipeDirection.In, clientHandle)) { for (int i = 1; i <= 5; i++) { Assert.Equal(i, pipe.ReadByte()); } Assert.Equal(-1, pipe.ReadByte()); } } }
async private Task <int> TestAsyncOutputStream_BeginCancelBeinOutputRead_RemotelyInvokable(string pipesHandle) { string[] pipeHandlers = pipesHandle.Split(' '); using (AnonymousPipeClientStream pipeRead = new AnonymousPipeClientStream(PipeDirection.In, pipeHandlers[0])) using (AnonymousPipeClientStream pipeWrite = new AnonymousPipeClientStream(PipeDirection.Out, pipeHandlers[1])) { // Signal child process start await pipeWrite.WriteAsync(new byte[1], 0, 1); // Wait parent signal to produce number 1,2,3 Assert.True(await WaitPipeSignal(pipeRead, WaitInMS), "Missing parent signal to produce number 1,2,3"); Console.WriteLine(1); Console.WriteLine(2); Console.WriteLine(3); await pipeWrite.WriteAsync(new byte[1], 0, 1); // Wait parent cancellation signal and produce new values 4,5,6 Assert.True(await WaitPipeSignal(pipeRead, WaitInMS), "Missing parent signal to produce number 4,5,6"); Console.WriteLine(4); Console.WriteLine(5); Console.WriteLine(6); // Wait parent re-start listening signal and produce 7,8,9 Assert.True(await WaitPipeSignal(pipeRead, WaitInMS), "Missing parent re-start listening signal"); Console.WriteLine(7); Console.WriteLine(8); Console.WriteLine(9); return(RemoteExecutor.SuccessExitCode); } }
public static ClientCommunicator OpenPipes(string inPipeId, string outPipeId) { var inStream = new AnonymousPipeClientStream(PipeDirection.In, inPipeId); var outStream = new AnonymousPipeClientStream(PipeDirection.Out, outPipeId); return(new ClientCommunicator(inStream, outStream)); }
private static int PingPong_OtherProcess(string inHandle, string outHandle) { // Create the clients associated with the supplied handles using (var inbound = new AnonymousPipeClientStream(PipeDirection.In, inHandle)) using (var outbound = new AnonymousPipeClientStream(PipeDirection.Out, outHandle)) { // Repeatedly read then write a byte from and to the server for (int i = 0; i < 10; i++) { int b = inbound.ReadByte(); outbound.WriteByte((byte)b); } } return SuccessExitCode; }
public static void DisposeLocalCopyOfClientHandle_BeforeServerRead() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.In)) { using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { byte[] sent = new byte[] { 123 }; byte[] received = new byte[] { 0 }; client.Write(sent, 0, 1); server.DisposeLocalCopyOfClientHandle(); Assert.Equal(1, server.Read(received, 0, 1)); Assert.Equal(sent[0], received[0]); } } }
public static void ClonedClient_ActsAsOriginalClient() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) { using (AnonymousPipeClientStream clientBase = new AnonymousPipeClientStream(PipeDirection.In, server.GetClientHandleAsString())) { using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, clientBase.SafePipeHandle)) { Assert.True(server.IsConnected); Assert.True(client.IsConnected); byte[] sent = new byte[] { 123 }; byte[] received = new byte[] { 0 }; server.Write(sent, 0, 1); Assert.Equal(1, client.Read(received, 0, 1)); Assert.Equal(sent[0], received[0]); } } } }
public static void CreateClientStreamFromStringHandle_Valid() { using (var server = new AnonymousPipeServerStream(PipeDirection.Out)) using (var client = new AnonymousPipeClientStream(server.GetClientHandleAsString())) { } }
public static void ClientUnsupportedOperationThrows() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.In)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { ConnectedPipeUnsupportedOperationThrows(client); } }
public static void ClientReadOnlyDisconnectedPipeThrows() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, server.ClientSafePipeHandle)) { client.Dispose(); OtherSidePipeDisconnectWriteThrows(server); } }
public static void ClientReadOnlyCancelReadTokenThrows() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, server.ClientSafePipeHandle)) { ConnectedPipeCancelReadTokenThrows(client); } }
public static void ClientReadArrayOutOfBoundsThrows() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, server.ClientSafePipeHandle)) { ConnectedPipeReadArrayOutOfBoundsThrows(client); } }
public static void OSX_BufferSizeNotSupported() { int desiredBufferSize = 10; using (var server = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.None, desiredBufferSize)) using (var client = new AnonymousPipeClientStream(PipeDirection.In, server.ClientSafePipeHandle)) { Assert.Throws<PlatformNotSupportedException>(() => server.OutBufferSize); Assert.Throws<PlatformNotSupportedException>(() => client.InBufferSize); } }
public static void Windows_BufferSizeRoundtripping() { // On Windows, setting the buffer size of the server will only set // the buffer size of the client if the flow of the pipe is towards the client i.e. // the client is defined with PipeDirection.In int desiredBufferSize = 10; using (var server = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.None, desiredBufferSize)) using (var client = new AnonymousPipeClientStream(PipeDirection.In, server.ClientSafePipeHandle)) { Assert.Equal(desiredBufferSize, server.OutBufferSize); Assert.Equal(desiredBufferSize, client.InBufferSize); } using (var server = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.None, desiredBufferSize)) using (var client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { Assert.Equal(desiredBufferSize, server.InBufferSize); Assert.Equal(0, client.OutBufferSize); } }
public void InvalidReadMode_Throws_ArgumentOutOfRangeException() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, server.GetClientHandleAsString())) { Assert.Throws<ArgumentOutOfRangeException>(() => server.ReadMode = (PipeTransmissionMode)999); Assert.Throws<ArgumentOutOfRangeException>(() => client.ReadMode = (PipeTransmissionMode)999); } }
public void MessageReadMode_Throws_NotSupportedException() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, server.GetClientHandleAsString())) { Assert.Throws<NotSupportedException>(() => server.ReadMode = PipeTransmissionMode.Message); Assert.Throws<NotSupportedException>(() => client.ReadMode = PipeTransmissionMode.Message); } }
public void ReadModeToByte_Accepted(PipeDirection serverDirection, PipeDirection clientDirection) { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(serverDirection)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(clientDirection, server.GetClientHandleAsString())) { server.ReadMode = PipeTransmissionMode.Byte; client.ReadMode = PipeTransmissionMode.Byte; Assert.Equal(PipeTransmissionMode.Byte, server.ReadMode); Assert.Equal(PipeTransmissionMode.Byte, client.ReadMode); } }
public static void ClientReadModeThrows() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.In)) { using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { Assert.Throws<ArgumentOutOfRangeException>(() => client.ReadMode = (PipeTransmissionMode)999); Assert.Throws<NotSupportedException>(() => client.ReadMode = PipeTransmissionMode.Message); } } }
public static void ClientWriteNegativeCountThrows() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.In)) using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { ConnectedPipeWriteNegativeCountThrows(client); } }