Table of Contents

Interface ISocketFactory

Namespace
VpnHood.Net.Toolkit.Sockets
Assembly
VpnHood.Net.Toolkit.dll

Represents a factory of the sockets an app uses, so a platform or a decorator can protect, bind or configure each one, such as to keep it out of a VPN's tunnel.

public interface ISocketFactory

Methods

CreateTcpClient(IPEndPoint, TcpClientOptions?)

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

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.

CreateUdpClient(AddressFamily)

Creates a UDP client of an address family.

UdpClient CreateUdpClient(AddressFamily addressFamily)

Parameters

addressFamily AddressFamily

The address family.

Returns

UdpClient

The UDP client, which the caller owns and disposes.

CreateUdpSocket(AddressFamily)

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

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.