DnsEndPoint Constructor (String^, Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the DnsEndPoint class with the host name or string representation of an IP address and a port number.

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

	String^ host,
	int port


Type: System::String^

The host name or a string representation of the IP address.

Type: System::Int32

The port number associated with the address, or 0 to specify any available port. port is in host order.

Exception Condition

The host parameter contains an empty string.


The host parameter is a null.


port is less than MinPort.


port is greater than MaxPort.

The DnsEndPoint(String^, Int32) constructor can be used to initialize a DnsEndPoint class using either a host name or a string that represents an IP address and a port. This constructor sets the AddressFamily property to Unknown.

When using this constructor with a host name rather than a string representation of an IP address, the address family of the DnsEndPoint will remain Unknown even after use. The AddressFamily property of any Socket that is created by calls to the ConnectAsync method will be the address family of the first address to which a connection can be successfully established (not necessarily the first address to be resolved).

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.0
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Return to top