Class IPEndPoint
Represents a network endpoint as an IP address and a port number.
Inherited Members
Namespace: System.Net
Assembly: System.Net.dll
Syntax
public class IPEndPoint : EndPoint
Constructors
IPEndPoint(long, int)
Initializes a new instance of the IPEndPoint class with the specified address and port number.
Declaration
public IPEndPoint(long address, int port)
Parameters
Type | Name | Description |
---|---|---|
long | address | The IP address of the Internet host. |
int | port | The port number associated with the address, or 0 to specify any available port. port is in host order. |
IPEndPoint(IPAddress, int)
Initializes a new instance of the IPEndPoint class with the specified address and port number.
Declaration
public IPEndPoint(IPAddress address, int port)
Parameters
Type | Name | Description |
---|---|---|
IPAddress | address | |
int | port |
Fields
MaxPort
Specifies the maximum value that can be assigned to the Port property. The MaxPort value is set to 0x0000FFFF. This field is read-only.
Declaration
public const int MaxPort = 65535
Field Value
Type | Description |
---|---|
int |
MinPort
Specifies the minimum value that can be assigned to the Port property. This field is read-only.
Declaration
public const int MinPort = 0
Field Value
Type | Description |
---|---|
int |
Properties
Address
Gets or sets the IP address of the endpoint.
Declaration
public IPAddress Address { get; }
Property Value
Type | Description |
---|---|
IPAddress | An IPAddress instance containing the IP address of the endpoint. |
AddressFamily
Gets the Internet Protocol (IP) address family.
Declaration
public AddressFamily AddressFamily { get; }
Property Value
Type | Description |
---|---|
AddressFamily | Returns InterNetwork. |
Port
Gets or sets the port number of the endpoint.
Declaration
public int Port { get; }
Property Value
Type | Description |
---|---|
int | An integer value in the range MinPort to MaxPort indicating the port number of the endpoint. |
Methods
Create(SocketAddress)
Creates an endpoint from a socket address.
Declaration
public override EndPoint Create(SocketAddress socketAddress)
Parameters
Type | Name | Description |
---|---|---|
SocketAddress | socketAddress | The SocketAddress to use for the endpoint. |
Returns
Type | Description |
---|---|
EndPoint | An EndPoint instance using the specified socket address. |
Overrides
Equals(object)
Determines whether the specified Object is equal to the current IPEndPoint instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The specified Object to compare with the current IPEndPoint instance. |
Returns
Type | Description |
---|---|
bool | true if the objects are equal. |
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
Serialize()
Serializes endpoint information into a SocketAddress instance.
Declaration
public override SocketAddress Serialize()
Returns
Type | Description |
---|---|
SocketAddress | A SocketAddress instance containing the socket address for the endpoint. |
Overrides
ToString()
Returns the IP address and port number of the specified endpoint.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string containing the IP address and the port number of the specified endpoint (for example, 192.168.1.2:80). |