Struct IpEndPointValue
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
Exceptions
- ArgumentNullException
addressis 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
addressValueIpAddressValueThe address.
portintThe port.
Properties
Address
Gets the address.
public IPAddress Address { get; init; }
Property Value
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
Port
Gets the port.
public int Port { get; init; }
Property Value
Methods
Deconstruct(out IPAddress, out int)
Deconstructs the endpoint into its address and port.
public void Deconstruct(out IPAddress address, out int port)
Parameters
addressIPAddressWhen this method returns, the address.
portintWhen 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.