Table of Contents

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

configFolder string

The 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

request Memory<byte>

The request's bytes.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<Memory<byte>>

A task whose result is the answer's bytes.

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

cancellationToken was canceled.