Table of Contents

Struct IpEndPointValue

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

Represents an IP endpoint as a value: an address and a port, compared by value.

public readonly record struct IpEndPointValue : IEquatable<IpEndPointValue>
Implements
Inherited Members

Remarks

The address is held as an IpAddressValue, with no object on the heap, and Address makes an IPAddress from it on each read. Two endpoints are equal when their ports are and their addresses are, as Equals(object) compares them. The default value holds no address.

Constructors

IpEndPointValue(IPAddress, int)

Initializes a new instance of the IpEndPointValue structure from an address and a port.

public IpEndPointValue(IPAddress address, int port)

Parameters

address IPAddress

The address.

port int

The port.

Exceptions

ArgumentNullException

address is null.

IpEndPointValue(IpAddressValue, int)

Initializes a new instance of the IpEndPointValue structure from an address value and a port.

public IpEndPointValue(IpAddressValue addressValue, int port)

Parameters

addressValue IpAddressValue

The address.

port int

The port.

Properties

Address

Gets the address.

public IPAddress Address { get; init; }

Property Value

IPAddress

Remarks

Each read makes a new IPAddress; code that runs per packet reads AddressValue.

Exceptions

InvalidOperationException

The endpoint is the default value, which holds no address.

ArgumentNullException

The address set is null.

AddressValue

Gets the address as a value.

public IpAddressValue AddressValue { get; init; }

Property Value

IpAddressValue

Port

Gets the port.

public int Port { get; init; }

Property Value

int

Methods

Deconstruct(out IPAddress, out int)

Deconstructs the endpoint into its address and port.

public void Deconstruct(out IPAddress address, out int port)

Parameters

address IPAddress

When this method returns, the address.

port int

When this method returns, the port.

Exceptions

InvalidOperationException

The endpoint is the default value, which holds no address.

ToIPEndPoint()

Converts the value to an IPEndPoint.

public IPEndPoint ToIPEndPoint()

Returns

IPEndPoint

A new endpoint.

Exceptions

InvalidOperationException

The endpoint is the default value, which holds no address.

ArgumentOutOfRangeException

The port is out of range.