NamedPipeClientPoolLink
Namespace: TagBites.Pipes
Assembly: TagBites.Pipes.dll
Product: TagBites.Pipes v. 1.2.0
Holds one connection taken from a NamedPipeClientPool for as long as the link is alive, so several requests run on the same connection.
public class NamedPipeClientPoolLink : System.IDisposableInheritance: object → NamedPipeClientPoolLink
Remarks
Section titled “Remarks”Disposing the link returns the connection to the pool. Until then the pool cannot hand that connection to anyone else, so a link that is never disposed shrinks the pool by one.
Properties
Section titled “Properties”IsConnected
Section titled “IsConnected”Gets a value indicating whether the connection is believed to be alive.
public bool IsConnected { get; }Property Value
Section titled “Property Value”Remarks
Section titled “Remarks”This turns to false once a request fails or the client is disposed. A connection that the other side dropped while idle still reads as true, because a named pipe reveals that only when it is used.
IsDisposed
Section titled “IsDisposed”Gets a value indicating whether the connection has been returned to the pool.
public bool IsDisposed { get; }Property Value
Section titled “Property Value”PipeName
Section titled “PipeName”Gets the name of the pipe the connection points to.
public string PipeName { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”Connect()
Section titled “Connect()”Opens the connection and agrees an encoding with the server. Returns at once when the client is already connected.
public void Connect()Exceptions
Section titled “Exceptions”- TimeoutException - The server did not accept within the timeout.
- ObjectDisposedException - The client has been disposed.
Connect(int)
Section titled “Connect(int)”Opens the connection and agrees an encoding with the server. Returns at once when the client is already connected.
public void Connect(int timeout)Parameters
Section titled “Parameters”timeoutint
How long to wait for the server, in milliseconds. Default:100.
Exceptions
Section titled “Exceptions”- TimeoutException - The server did not accept within the timeout.
- ObjectDisposedException - The client has been disposed.
ConnectAsync()
Section titled “ConnectAsync()”Opens the connection and agrees an encoding with the server. Returns at once when the client is already connected.
public Task ConnectAsync()Returns
Section titled “Returns”Exceptions
Section titled “Exceptions”- TimeoutException - The server did not accept within the timeout.
- ObjectDisposedException - The client has been disposed.
ConnectAsync(int, CancellationToken)
Section titled “ConnectAsync(int, CancellationToken)”Opens the connection and agrees an encoding with the server. Returns at once when the client is already connected.
public Task ConnectAsync(int timeout, CancellationToken token)Parameters
Section titled “Parameters”timeoutint
How long to wait for the server, in milliseconds. Default:100.tokenCancellationToken
The token that cancels waiting for the server.
Returns
Section titled “Returns”Exceptions
Section titled “Exceptions”- TimeoutException - The server did not accept within the timeout.
- ObjectDisposedException - The client has been disposed.
Dispose()
Section titled “Dispose()”Returns the connection to the pool.
public virtual void Dispose()SendRequest(string, string)
Section titled “SendRequest(string, string)”Sends a request and waits for the response.
public string SendRequest(string address, string message)Parameters
Section titled “Parameters”addressstring
The address naming the operation. It must not start with--.messagestring
The message to send.
Returns
Section titled “Returns”The response text, which is empty when the handler set no response.
Exceptions
Section titled “Exceptions”- ArgumentNullException -
addressormessageisnull. - ArgumentException -
addressstarts with--, which is reserved. - InvalidOperationException - The client is not connected.
- NamedPipeConnectionLostException - The connection broke while sending or receiving.
- NamedPipeServerRemoteException - The request handler on the server failed.
SendRequestAsync(string, string)
Section titled “SendRequestAsync(string, string)”Sends a request and waits for the response.
public Task<string> SendRequestAsync(string address, string message)Parameters
Section titled “Parameters”addressstring
The address naming the operation. It must not start with--.messagestring
The message to send.
Returns
Section titled “Returns”The response text, which is empty when the handler set no response.
Exceptions
Section titled “Exceptions”- ArgumentNullException -
addressormessageisnull. - ArgumentException -
addressstarts with--, which is reserved. - InvalidOperationException - The client is not connected.
- NamedPipeConnectionLostException - The connection broke while sending or receiving.
- NamedPipeServerRemoteException - The request handler on the server failed.