Table of Contents

Class ConfiguringSocketFactory

Namespace
VpnHood.Core.Tunneling.Sockets
Assembly
VpnHood.Core.Tunneling.dll

Provides the sockets of another factory, with the common settings on its TCP clients: keep-alive, no delay, and the kernel's send and receive buffer sizes.

public class ConfiguringSocketFactory : ISocketFactory
Inheritance
ConfiguringSocketFactory
Implements
Inherited Members

Remarks

It keeps those settings in one place, so the inner factories only make and protect sockets.

Constructors

ConfiguringSocketFactory(ISocketFactory)

Provides the sockets of another factory, with the common settings on its TCP clients: keep-alive, no delay, and the kernel's send and receive buffer sizes.

public ConfiguringSocketFactory(ISocketFactory inner)

Parameters

inner ISocketFactory

The factory that makes the sockets.

Remarks

It keeps those settings in one place, so the inner factories only make and protect sockets.

Properties

KeepAlive

Gets or sets a value indicating whether the TCP clients send keep-alives; where false, a client keeps its own setting.

public bool KeepAlive { get; set; }

Property Value

bool

NoDelay

Gets or sets a value indicating whether the TCP clients send without Nagle's delay.

public bool NoDelay { get; set; }

Property Value

bool

TcpKernelBufferSize

Gets or sets the kernel's send and receive buffer sizes for a TCP client asked for without options of its own, or null for the system's. It may change at any time, as a server's reconfiguration does.

public TransferBufferSize? TcpKernelBufferSize { get; set; }

Property Value

TransferBufferSize?

Methods

CreateTcpClient(IPEndPoint, TcpClientOptions?)

Creates a TCP client for an endpoint's address family, not connected yet.

public TcpClient CreateTcpClient(IPEndPoint ipEndPoint, TcpClientOptions? options = null)

Parameters

ipEndPoint IPEndPoint

The endpoint the client will connect to; its address family is the client's.

options TcpClientOptions

The client's options, or null for the defaults.

Returns

TcpClient

The TCP client, which the caller owns and disposes.

Remarks

Options given win as a whole: a null kernel buffer size in them means the system's, not this factory's.

CreateUdpClient(AddressFamily)

Creates a UDP client of an address family.

public UdpClient CreateUdpClient(AddressFamily addressFamily)

Parameters

addressFamily AddressFamily

The address family.

Returns

UdpClient

The UDP client, which the caller owns and disposes.

Remarks

It is the inner factory's, as it is.

CreateUdpSocket(AddressFamily)

Creates a UDP socket of an address family, for a worker that manages its own receive buffer.

public Socket CreateUdpSocket(AddressFamily addressFamily)

Parameters

addressFamily AddressFamily

The address family.

Returns

Socket

The socket, which the caller owns and disposes.

Remarks

A UdpClient keeps a receive buffer of its own, too costly for small-buffer workers such as DNS. The interface's default implementation returns the socket of CreateUdpClient(AddressFamily), so a factory that does not implement it keeps its protection, binding and configuration.