Table of Contents

Class ReusableStreamConnection

Namespace
VpnHood.Core.Tunneling.Connections
Assembly
VpnHood.Core.Tunneling.dll

Represents a connection that carries one logical stream of the many its transport carries in turn.

public class ReusableStreamConnection : IStreamConnection, IDisposable, IAsyncDisposable
Inheritance
ReusableStreamConnection
Implements
Inherited Members

Remarks

Its release, DisposeAsync(), ends that stream with the peer and, if it ends cleanly, hands the transport, under its next logical stream, to the reuse callback, which keeps or closes it. PreventReuse(), an unclean end or no callback closes the transport instead. Its quick close, Dispose(), closes the transport at once, with no end of the logical stream and no reuse.

Constructors

ReusableStreamConnection(IStreamConnection, ChunkStream, ReuseConnectionCallback?)

Initializes a new instance of the ReusableStreamConnection class.

public ReusableStreamConnection(IStreamConnection transport, ChunkStream stream, ReuseConnectionCallback? reuseCallback)

Parameters

transport IStreamConnection

The connection that carries the logical streams.

stream ChunkStream

The logical stream this connection carries.

reuseCallback ReuseConnectionCallback

The method that takes the transport for another request, or null to close it at the release.

Properties

Connected

Gets a value indicating whether the connection is up.

public bool Connected { get; }

Property Value

bool

ConnectionId

Gets or sets the connection's ID, which its logs carry.

public string ConnectionId { get; set; }

Property Value

string

Remarks

Setting it sets the logical stream's ID too.

ConnectionName

Gets the connection's name, which its logs carry.

public string ConnectionName { get; }

Property Value

string

IsServer

Gets a value indicating whether this is the server's side of the connection, which its logs show.

public bool IsServer { get; }

Property Value

bool

LocalEndPoint

Gets the connection's local endpoint.

public IPEndPoint LocalEndPoint { get; }

Property Value

IPEndPoint

RemoteEndPoint

Gets the peer's endpoint.

public IPEndPoint RemoteEndPoint { get; }

Property Value

IPEndPoint

RequireHttpResponse

Gets or sets a value indicating whether an HTTP response to the connection's request header is still due before the request's own answer: the server writes it, and the client reads it.

public bool RequireHttpResponse { get; set; }

Property Value

bool

Stream

Gets the stream the connection carries.

public Stream Stream { get; }

Property Value

Stream

Remarks

It is the logical stream.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Remarks

The quick close: it closes the transport at once, with no end of the logical stream and no reuse, unless the release has handed the transport on.

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

Remarks

The release: it ends the logical stream with the peer and hands the transport to the reuse callback, or closes it; a failure is logged and closes it. A second call waits for the first one's end.

PreventReuse()

Makes the connection's release close it rather than keep it for another request.

public void PreventReuse()

Remarks

A decorator passes it on, so it reaches the reusable connection however that is wrapped.