EndpointPair EndpointPair EndpointPair EndpointPair Class

Provides data for the local endpoint and remote endpoint for a network connection used by network apps.

Syntax

Declaration

public sealed class EndpointPairpublic sealed class EndpointPairPublic NotInheritable Class EndpointPairpublic sealed class EndpointPair

Remarks

The EndpointPair class is used to initialize and provide data for an endpoint pair used in network apps. The EndpointPair object provides data for the local endpoint and remote endpoint for a network connection. The EndpointPair object is used by many classes in other related namespaces for network apps. These include the following:

  • Many classes in the Windows.Networking.Sockets namespace using sockets. Methods on the DatagramSocket and StreamSocket classes can be used to establish network connections and transfer data using an EndpointPair object.
  • The NetworkInformation class in the Windows.Networking.Connectivity namespace. An endpoint consists of two elements:

  • The hostname or IP address.

  • The service name or the TCP or UDP port number. An endpoint pair consists of two elements:

  • The local endpoint.

  • The remote endpoint. If the local hostname is null for the local endpoint 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.

If the local service name is an empty string for the local endpoint before a network connection is established by a client app, then the system will automatically provide a TCP or UDP port for the app to use.

The WiFiDirectDevice class can be used to locate other devices that have a Wi-Fi Direct (WFD) capable device. The GetDeviceSelector(WiFiDirectDeviceSelectorType) method gets the device identifier for a nearby WFD device. Once you have a reference to a nearby WFD device, you can call the GetConnectionEndpointPairs() method to get an EndpointPair object.

Constructors summary

Creates a new EndpointPair object.

Properties summary

Get or set the local hostname for the EndpointPair object.

Get or set the local service name for the EndpointPair object.

Get or set the remote hostname for the EndpointPair object.

Get or set the remote service name for the EndpointPair object.

Constructors

  • EndpointPair(HostName, String, HostName, String)
    EndpointPair(HostName, String, HostName, String)
    EndpointPair(HostName, String, HostName, String)
    EndpointPair(HostName, String, HostName, String)

    Creates a new EndpointPair object.

    public EndpointPair(HostName localHostName, String localServiceName, HostName remoteHostName, String remoteServiceName)public New(HostName localHostName, String localServiceName, HostName remoteHostName, String remoteServiceName)Public Sub New(localHostName As HostName, localServiceName As String, remoteHostName As HostName, remoteServiceName As String)public EndpointPair(HostName localHostName, String localServiceName, HostName remoteHostName, String remoteServiceName)

    Parameters

    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 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.

Properties

  • LocalHostName
    LocalHostName
    LocalHostName
    LocalHostName

    Get or set the local hostname for the EndpointPair object.

    public HostName LocalHostName { get; set; }public HostName LocalHostName { get; set; }Public ReadWrite Property LocalHostName As HostNamepublic HostName LocalHostName { get; set; }

    Property Value

    Remarks

    The LocalHostName property can contain a local hostname or an IP address.

    The LocalHostName property can be set to 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). When this property is set to the "localhost" string, this represents all loopback addresses on the local computer.

    The GetHostNames() method in the Windows.Networking.Connectivity namespace can be used to retrieve a list of hostnames or IP addresses associated with the local machine. The LocalHostName property can then be set to one of these hostnames or IP addresses.

    The LocalHostName property can also be set to null. If the LocalHostName property 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.

  • LocalServiceName
    LocalServiceName
    LocalServiceName
    LocalServiceName

    Get or set the local service name for the EndpointPair object.

    public string LocalServiceName { get; set; }public string LocalServiceName { get; set; }Public ReadWrite Property LocalServiceName As stringpublic string LocalServiceName { get; set; }

    Property Value

    • string
      string
      string
      string

      The local service name for the EndpointPair object.

    Remarks

    The LocalServiceName property can contain a service name or a TCP or UDP port number. The LocalServiceName property can be set to one of the following:

    • A numeric literal for a TCP or UDP port number (80 for the TCP port typically 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 property can also be set to 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 port number for the app to use when establishing a network connection.

    It is an error to set the LocalServiceName property to null.

  • RemoteHostName
    RemoteHostName
    RemoteHostName
    RemoteHostName

    Get or set the remote hostname for the EndpointPair object.

    public HostName RemoteHostName { get; set; }public HostName RemoteHostName { get; set; }Public ReadWrite Property RemoteHostName As HostNamepublic HostName RemoteHostName { get; set; }

    Property Value

    Remarks

    The RemoteHostName property can contain a hostname or an IP address to connect to. The remote hostname must be supplied for the remote endpoint of the EndpointPair object before a network connection can be established by a client app.

    The RemoteHostName property can be set to 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). When this property is set to the "localhost" string, this represents all loopback addresses on the local computer.

    It is an error to set the RemoteHostName property to null or an empty string.

  • RemoteServiceName
    RemoteServiceName
    RemoteServiceName
    RemoteServiceName

    Get or set the remote service name for the EndpointPair object.

    public string RemoteServiceName { get; set; }public string RemoteServiceName { get; set; }Public ReadWrite Property RemoteServiceName As stringpublic string RemoteServiceName { get; set; }

    Property Value

    • string
      string
      string
      string

      The remote service name for the EndpointPair object.

    Remarks

    The RemoteServiceName property can contain a service name or a TCP or UDP port number for a remote network destination. The remote service name must be supplied for the remote endpoint of the EndpointPair object before a network connection can be established by a client app.

    The RemoteServiceName property can be set to 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. It is an error to set the RemoteServiceName property to null.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Networking.dll