NamedPipeServerStream server = new NamedPipeServerStream("pipeName"); // listen for connections server.WaitForConnection(); // perform operations with connected client // close the server stream when done server.Close();
// get the named pipe server stream associated with the client connection NamedPipeServerStream server = connectedClient.GetStream(); // send a message or perform operations with the connected client // close the server stream to terminate the connection server.Close();The NamedPipeServerStream.Close method is part of the System.IO.Pipes namespace in the .NET framework.