IPEndPoint Class

public sealed class IPEndPoint : EndPoint

Summary

Represents a network endpoint as an IP address and a port number.

The IPEndPoint class is used to represent a network endpoint that consists of an IP address and a port number. It is part of the System.Net.Sockets namespace and is commonly used in network programming to specify the destination or source of network communication.

Remarks

An IPEndPoint object uniquely identifies a process on a network. It combines an IPAddress with a port number. The port number is a 16-bit unsigned integer that identifies a specific application or service on a host. For example, the well-known HTTP port is 80, and the HTTPS port is 443.

When working with TCP/IP sockets, you often need to bind a socket to a specific IPEndPoint or connect a socket to a remote IPEndPoint. The AddressFamily property of the IPEndPoint indicates whether the endpoint is for IPv4 or IPv6.

Common scenarios for using IPEndPoint include:

Constructors

Name Description
IPEndPoint(IPAddress, int) Initializes a new instance of the IPEndPoint class with the specified IP address and port number.
IPEndPoint(long, int) Initializes a new instance of the IPEndPoint class with the specified IP address (as a 64-bit integer) and port number.

Properties

Name Type Description
Address IPAddress Gets or sets the IP address of the endpoint.
Port int Gets or sets the port number of the endpoint.

Methods

Name Description
CreateSocketAddress() Creates a SocketAddress object from the IPEndPoint. (Overridden from EndPoint)
Equals(object obj) Determines whether the specified object is equal to the current object.
GetHashCode() Serves as the default hash function.
Parse(string s) Parses an IP endpoint string and returns an IPEndPoint instance.
ToString() Returns a string representation of the IPEndPoint.

See Also

System.Net.Sockets Namespace
.NET API Reference
IPAddress Socket