EndpointPair.EndpointPair constructor

Applies to Windows and Windows Phone

Creates a new EndpointPair object.

Syntax


var endpointPair = new Windows.Networking.EndpointPair(localHostName, localServiceName, remoteHostName, remoteServiceName);

Parameters

localHostName

Type: HostName

The local hostname or IP address for the EndpointPair object.

localServiceName

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The local service name or the local TCP or UDP port number for the EndpointPair object.

remoteHostName

Type: HostName

The remote hostname or IP address for the EndpointPair object.

remoteServiceName

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The remote service name or the remote TCP or UDP port number for the EndpointPair object.

Remarks

This constructor creates a new EndpointPair object from a local hostname, a local service name, a remote hostname, and a remote service name. The EndpointPair object provides data used by network apps for the local endpoint and remote endpoint for a network connection.

An endpoint consists of two components:

  • The hostname or IP address.
  • The service name or the TCP or UDP port number.

An endpoint pair consists of two components:

  • The local endpoint for a network connection.
  • The remote endpoint for a network connection.

The localHostName parameter can contain one of the following:

  • The name of the local host that can be resolved by the Domain Name System (DNS) or by another namespace provider.
  • The name of the local host that matches a string in the following file on the local computer: %WINDIR%\\system32\drivers\etc\hosts
  • A string that contains an IPv4 or an IPv6 network address of the local host. An IPv4 address string is in dotted-decimal notation ("192.168.1.111", for example). An IPv6 address is in hexadecimal notation ("21DA:00D3:0010:2F3B:02AA:00FF:FE28:9C5A", for example).

If the localHostName parameter is the "localhost" string, this represents all loopback addresses on the local computer.

The NetworkInformation.GetHostNames method in the Windows.Networking.Connectivity namespace can be used to retrieve a list of host names or IP addresses associated with the local machine. One of these hostnames or IP addresses can then be used for the localHostName parameter.

The localHostName parameter can also be set to null. If the localHostName is null before a network connection is established by a client app, then the system will automatically provide the local IP address for the app to use.

The localServiceName parameter can contain one of the following:

  • A numeric literal for a TCP or UDP port number (80 for the TCP port used for http, for example).
  • A string alias for a port number ("http", for example) that matches a string in the following file on the local computer: %WINDIR%\system32\drivers\etc\services
  • A service name that can be resolved by a namespace provider using a SRV record.

The localServiceName parameter can also contain an empty string. If the local service name is an empty string for the local endpoint before a network connection is established, then the system will automatically provide a TCP or UDP IP port number for the app to use when establishing a network connection.

The constructor will fail if the localServiceName parameter is null.

The remoteHostName parameter can contain one of the following:

  • The name of the remote host that can be resolved by the Domain Name System (DNS) or by another namespace provider.
  • The name of the host that matches a string in the following file on the local computer: %WINDIR%\\system32\drivers\etc\hosts
  • A string that contains an IPv4 or an IPv6 network address of the remote host. An IPv4 address string is in dotted-decimal notation ("192.168.1.111", for example). An IPv6 address is in hexadecimal notation ("21DA:00D3:0010:2F3B:02AA:00FF:FE28:9C5A", for example).

If the remoteHostName parameter is the "localhost" string, this represents all loopback addresses on the local computer.

The constructor will fail if the remoteHostName parameter is null or contains an empty string.

The remoteServiceName parameter can contain one of the following:

  • A numeric literal for a TCP or UDP port number (80 for the TCP port used for http, for example).
  • A string alias for a port number ("http", for example) that matches a string in the following file on the local computer: %WINDIR%\system32\drivers\etc\services
  • A service name that can be resolved by a namespace provider using a SRV record.

The constructor will fail if the remoteServiceName parameter is null or contains an empty string.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

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

Metadata

Windows.winmd

DLL

Windows.Networking.dll

See also

EndpointPair
Windows.Networking

 

 

Show:
© 2014 Microsoft