Class TcpMessageClient
- Namespace
- VpnHood.Core.Client.VpnServices.Abstractions.Messaging
- Assembly
- VpnHood.Core.Client.VpnServices.Abstractions.dll
Represents the app's side of the loopback TCP channel to the VPN service: one connection to TcpMessageListener, kept, and made again when it drops, to the endpoint and with the key the listener published in the config folder.
public sealed class TcpMessageClient : IMessageClient, IDisposable
- Inheritance
-
TcpMessageClient
- Implements
- Inherited Members
Constructors
TcpMessageClient(string)
Represents the app's side of the loopback TCP channel to the VPN service: one connection to TcpMessageListener, kept, and made again when it drops, to the endpoint and with the key the listener published in the config folder.
public TcpMessageClient(string configFolder)
Parameters
configFolderstringThe VPN service's config folder, where the listener publishes its endpoint and key.
Methods
Dispose()
Closes the connection.
public void Dispose()
SendAsync(Memory<byte>, CancellationToken)
Sends a request and returns the answer.
public Task<Memory<byte>> SendAsync(Memory<byte> request, CancellationToken cancellationToken)
Parameters
requestMemory<byte>The request's bytes.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Remarks
The transport owns making the connection, keeping it for reuse, and connecting again.
Exceptions
- VpnServiceNotReadyException
The listener's file is missing or cannot be read.
- VpnServiceUnreachableException
The service cannot be reached, or the connection failed before its answer; an answer that never comes is waited for until the token is canceled.
- ObjectDisposedException
The client is disposed.
- OperationCanceledException
cancellationTokenwas canceled.