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.IDisposableInheritance: object → NamedPipeServer
Remarks
Section titled “Remarks”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.
Constructors
Section titled “Constructors”NamedPipeServer(string)
Section titled “NamedPipeServer(string)”Initializes a new instance of the NamedPipeServer class.
public NamedPipeServer(string pipeName)Parameters
Section titled “Parameters”pipeNamestring
The name of the pipe to listen on.
Exceptions
Section titled “Exceptions”- ArgumentNullException -
pipeNameisnull.
Properties
Section titled “Properties”Enabled
Section titled “Enabled”Gets or sets a value indicating whether the server listens for connections.
public bool Enabled { get; set; }Property Value
Section titled “Property Value”Remarks
Section titled “Remarks”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.
IncludeExceptionStackTrace
Section titled “IncludeExceptionStackTrace”Gets or sets a value indicating whether the stack trace of a failed request is sent to the client.
public bool IncludeExceptionStackTrace { get; set; }Property Value
Section titled “Property Value”Remarks
Section titled “Remarks”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.
IsDisposed
Section titled “IsDisposed”Gets a value indicating whether the server has been disposed.
public bool IsDisposed { get; }Property Value
Section titled “Property Value”PipeName
Section titled “PipeName”Gets the name of the pipe the server listens on.
public string PipeName { get; }Property Value
Section titled “Property Value”SupportLegacyEncoding
Section titled “SupportLegacyEncoding”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; }Property Value
Section titled “Property Value”Remarks
Section titled “Remarks”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.
UseMessageStream
Section titled “UseMessageStream”Gets or sets a value indicating whether a request reaches the handler as a stream rather than a string.
public bool UseMessageStream { get; set; }Property Value
Section titled “Property Value”Remarks
Section titled “Remarks”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.
Methods
Section titled “Methods”Dispose()
Section titled “Dispose()”Stops the server and closes every open connection. The instance cannot be enabled again.
public virtual void Dispose()Events
Section titled “Events”Request
Section titled “Request”Occurs when a client sends a request.
public EventHandler<NamedPipeRequestEventArgs> RequestEvent Type
Section titled “Event Type”EventHandler<NamedPipeRequestEventArgs>
Remarks
Section titled “Remarks”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.