Skip to content
Auto
Products

NamedPipeServer

Namespace: TagBites.Pipes
Assembly: TagBites.Pipes.dll
Product: TagBites.Pipes v. 1.2.0

Accepts client connections on a named pipe and raises Request for every request.

public class NamedPipeServer : System.IDisposable

Inheritance: object → NamedPipeServer

The server accepts nothing until Enabled is set to true. Each connection is served on its own task, so requests from different clients run in parallel.

Initializes a new instance of the NamedPipeServer class.

public NamedPipeServer(string pipeName)
  • pipeName string
    The name of the pipe to listen on.

Gets or sets a value indicating whether the server listens for connections.

public bool Enabled { get; set; }

bool

The server listens as soon as this is set to true. Setting it to false stops accepting and closes every connection that is still open, so a client in the middle of a request gets NamedPipeConnectionLostException. Default: false.

Gets or sets a value indicating whether the stack trace of a failed request is sent to the client.

public bool IncludeExceptionStackTrace { get; set; }

bool

The client reads it as NamedPipeServerRemoteException.RemoteStackTrace. Set to false when a process that must not learn about the server internals can open the pipe. The exception type and message are always sent. Default: true.

Gets a value indicating whether the server has been disposed.

public bool IsDisposed { get; }

bool

Gets the name of the pipe the server listens on.

public string PipeName { get; }

string

Gets or sets a value indicating whether a client that does not negotiate an encoding is served with the encoding that predates version 2.

public bool SupportLegacyEncoding { get; set; }

bool

Every released version of this library speaks version 2, so leaving this off is correct for all of them. Turn it on only for a peer built before version 2 existed. Version 1 escapes line breaks only and drops trailing whitespace, so turning it on for a peer that speaks version 2 corrupts backslashes. Default: false.

Gets or sets a value indicating whether a request reaches the handler as a stream rather than a string.

public bool UseMessageStream { get; set; }

bool

Turn this on to read a large request without holding it in memory, through NamedPipeRequestEventArgs.MessageStream. NamedPipeRequestEventArgs.Message then throws, because the message is never built as a string. Existing handlers keep working while this stays off. Default: false.

Stops the server and closes every open connection. The instance cannot be enabled again.

public virtual void Dispose()

Occurs when a client sends a request.

public EventHandler<NamedPipeRequestEventArgs> Request

EventHandler<NamedPipeRequestEventArgs>

The handler runs on a thread pool thread and has no synchronization context, so code that touches a user interface has to marshal itself. Set NamedPipeRequestEventArgs.Response to answer, or NamedPipeRequestEventArgs.ResultTask to answer asynchronously. An exception thrown here reaches the client as NamedPipeServerRemoteException.