IPEndPoint Class

Namespace: System.Net

Assembly: System.Net.Primitives (in System.Net.Primitives.dll)

Remarks

The IPEndPoint class represents a network endpoint as an IP address and a port number. It is used to identify a specific process on a specific machine. This class is an immutable object, meaning its properties cannot be changed after it has been created.

IPEndPoint can represent an IPv4 or an IPv6 endpoint. The AddressFamily property determines whether the endpoint uses IPv4 or IPv6.

Constructors

Name Description
IPEndPoint(IPAddress, Int32) Initializes a new instance of the IPEndPoint class with the specified IP address and port number.
IPEndPoint(Int64, Int32) Initializes a new instance of the IPEndPoint class with the specified address family and port number.

Properties

Name Description
Address Gets or sets the IP address of the endpoint.
AddressFamily Gets the address family of the endpoint.
Port Gets or sets the port number of the endpoint.

Methods

Name Description
Create(Int64) Creates a new IPEndPoint instance from the specified 64-bit integer.
Equals(Object) Determines whether the specified object is an IPEndPoint that is equivalent to this instance.
GetHashCode() Serves as a hash function for the type.
Parse(String) Parses a string representation of an endpoint and returns an IPEndPoint instance.
ToString() Returns a string representation of the IPEndPoint.

Constructor Details

IPEndPoint(IPAddress, Int32)

public IPEndPoint(IPAddress address, int port);

Parameters

IPEndPoint(Int64, Int32)

public IPEndPoint(long unAddress, int port);

Parameters

Property Details

Address

public IPAddress Address { get; set; }

Gets or sets the IP address of the endpoint.

AddressFamily

public AddressFamily AddressFamily { get; }

Gets the address family of the endpoint.

Port

public int Port { get; set; }

Gets or sets the port number of the endpoint.

Method Details

Create(Int64)

public static EndPoint Create(long unAddress);

Creates a new IPEndPoint instance from the specified 64-bit integer.

Parameters

Return Value

System.Net.EndPoint
A new IPEndPoint instance.

Equals(Object)

public override bool Equals(object obj);

Determines whether the specified object is an IPEndPoint that is equivalent to this instance.

Parameters

Return Value

System.Boolean
true if the specified object is an IPEndPoint that is equivalent to this instance; otherwise, false.

GetHashCode()

public override int GetHashCode();

Serves as a hash function for the type. Suitable for use in hashing algorithms and data structures such as a hash table.

Return Value

System.Int32
A hash code for the current object.

Parse(String)

public static IPEndPoint Parse(string s);

Parses a string representation of an endpoint and returns an IPEndPoint instance.

Parameters

Return Value

System.Net.IPEndPoint
An IPEndPoint instance representing the parsed endpoint.

ToString()

public override string ToString();

Returns a string representation of the IPEndPoint in the format "ipAddress:port".

Return Value

System.String
A string representation of the IPEndPoint.

See Also

IPAddress Class | EndPoint Class | System.Net Namespace