HostName HostName HostName HostName HostName Class

Definition

Provides data for a hostname or an IP address.

public : sealed class HostName : IStringable, IHostName
struct winrt::Windows::Networking::HostName : IStringable, IHostName
public sealed class HostName : IStringable, IHostName
Public NotInheritable Class HostName Implements IStringable, IHostName
var hostName = new hostName(hostName);
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
privateNetworkClientServer internetClient

Remarks

The HostName class is used to initialize and provide data for a hostname used in network apps. A HostName object can be used for a local hostname or a remote hostname used to establish a network connection.

The HostName object is used by many classes in other related namespaces for network apps. These include the following:


using Windows.Networking;
using Windows.Networking.Sockets;

var serverHost = new HostName("www.contoso.com");
var clientSocket = new Windows.Networking.Sockets.StreamSocket();

// Try to connect to the remote host
await clientSocket.ConnectAsync(serverHost, "http");
using Windows.Networking;
using Windows.Networking.Sockets;

HostName serverHost = new HostName("www.contoso.com");
StreamSocket clientSocket = new Windows.Networking.Sockets.StreamSocket();

// Try to connect to the remote host
await clientSocket.ConnectAsync(serverHost, "http");


using namespace Windows::Networking;
using namespace Windows::Networking::Sockets;

HostName^ serverHost= ref new HostName("www.contoso.com");
StreamSocket^ clientSocket = ref new StreamSocket();

// Try to connect to the remote host
clientSocket->ConnectAsync(serverHost, "http");

Constructors

HostName(String) HostName(String) HostName(String) HostName(String) HostName(String)

Creates a new HostName object from a string that contains a hostname or an IP address.

Properties

CanonicalName CanonicalName CanonicalName CanonicalName CanonicalName

Gets the canonical name for the HostName object.

DisplayName DisplayName DisplayName DisplayName DisplayName

Gets the display name for the HostName object.

IPInformation IPInformation IPInformation IPInformation IPInformation

Gets the IPInformation object for a local IP address assigned to a HostName object.

RawName RawName RawName RawName RawName

Gets the original string used to construct the HostName object.

Type Type Type Type Type

Gets the HostNameType of the HostName object.

Methods

Compare(String, String) Compare(String, String) Compare(String, String) Compare(String, String) Compare(String, String)

Compares two strings to determine if they represent the same hostname.

IsEqual(HostName) IsEqual(HostName) IsEqual(HostName) IsEqual(HostName) IsEqual(HostName)

Determines whether the specified HostName object has an equivalent value to the current HostName object.

ToString() ToString() ToString() ToString() ToString()

Returns a string that represents the HostName object.

See Also