Class IPProtoEndPoint
Represents an IP endpoint with an associated protocol type.
public class IPProtoEndPoint : IPEndPoint
- Inheritance
-
IPProtoEndPoint
- Inherited Members
Remarks
This class extends IPEndPoint to include the protocol type (TCP, UDP, etc.), allowing endpoints to be distinguished not only by address and port but also by protocol.
Constructors
IPProtoEndPoint(long, int, ProtocolType)
Initializes a new instance of the IPProtoEndPoint class with the specified address, port, and protocol.
public IPProtoEndPoint(long address, int port, ProtocolType protocol)
Parameters
addresslongThe IP address as a 64-bit integer.
portintThe port number.
protocolProtocolTypeThe protocol type.
IPProtoEndPoint(IPAddress, int, ProtocolType)
Initializes a new instance of the IPProtoEndPoint class with the specified address, port, and protocol.
public IPProtoEndPoint(IPAddress address, int port, ProtocolType protocol)
Parameters
addressIPAddressThe IP address.
portintThe port number.
protocolProtocolTypeThe protocol type.
IPProtoEndPoint(IPEndPoint, ProtocolType)
Initializes a new instance of the IPProtoEndPoint class from an existing endpoint with the specified protocol.
public IPProtoEndPoint(IPEndPoint endPoint, ProtocolType protocol)
Parameters
endPointIPEndPointThe IP endpoint to copy the address and port from.
protocolProtocolTypeThe protocol type.
Properties
Protocol
Gets or sets the protocol type for this endpoint.
public ProtocolType Protocol { get; set; }
Property Value
Methods
Equals(object)
Determines whether the specified object is equal to the current endpoint.
public override bool Equals(object comparand)
Parameters
comparandobjectThe object to compare with the current endpoint.
Returns
- bool
trueif the objects have the same address, port, and protocol; otherwise,false.
GetHashCode()
Returns a hash code for this endpoint.
public override int GetHashCode()
Returns
- int
A hash code combining the base endpoint hash code with the protocol type.
IsNat(IPAddress)
Determines whether the specified IP address is a private (NAT) address.
public static bool IsNat(IPAddress address)
Parameters
addressIPAddressThe IP address to check.
Returns
- bool
trueif the address is in a private address range (10.x.x.x, 172.16-31.x.x, or 192.168.x.x); otherwise,false.
ToString()
Returns a string representation of this endpoint.
public override string ToString()
Returns
- string
A string in the format "address:port:protocol".
Operators
operator ==(IPProtoEndPoint, IPProtoEndPoint)
Determines whether two IPProtoEndPoint instances are equal.
public static bool operator ==(IPProtoEndPoint left, IPProtoEndPoint right)
Parameters
leftIPProtoEndPointThe first endpoint to compare.
rightIPProtoEndPointThe second endpoint to compare.
Returns
- bool
trueif both endpoints are equal or both arenull; otherwise,false.
operator !=(IPProtoEndPoint, IPProtoEndPoint)
Determines whether two IPProtoEndPoint instances are not equal.
public static bool operator !=(IPProtoEndPoint left, IPProtoEndPoint right)
Parameters
leftIPProtoEndPointThe first endpoint to compare.
rightIPProtoEndPointThe second endpoint to compare.
Returns
- bool
trueif the endpoints are not equal; otherwise,false.