Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

HostName class

Applies to Windows and Windows Phone

Provides data for a hostname or an IP address.

Syntax


public ref class HostName sealed : IStringable

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

Members

The HostName class has these types of members:

Constructors

The HostName class has these constructors.

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

 

Methods

The HostName class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
Compare Compares two strings to determine if they represent the same hostname.
IsEqual Determines whether the specified HostName object has an equivalent value to the current HostName object.
ToString Returns a string that represents the HostName object.

 

Properties

The HostName class has these properties.

PropertyAccess typeDescription

CanonicalName

Read-onlyGets the canonical name for the HostName object.

DisplayName

Read-onlyGets the display name for the HostName object.

IPInformation

Read-onlyGets the IPInformation object for a local IP address assigned to a HostName object.

RawName

Read-onlyGets the original string used to construct the HostName object.

Type

Read-onlyGets the HostNameType of the HostName object.

 

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:

The following example creates a HostName and then tries to connect to the HostName using a StreamSocket.



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");


Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8

Namespace

Windows.Networking
Windows::Networking [C++]

Metadata

Windows.winmd

DLL

Windows.Networking.dll

Capabilities

internetClient
privateNetworkClientServer

See also

DatagramSocket
EndpointPair
IStringable
NetworkInformation
Object
StreamSocket
Windows.Networking
Windows.Networking.Sockets

 

 

Show:
© 2014 Microsoft