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.

HostNameSortOptions enumeration

Options for how a list of EndpointPair objects is sorted.


Public Enum HostNameSortOptions


The HostNameSortOptions enumeration has these members.

None | none0

Sort a list of EndpointPair objects by the default criteria used the system which is to minimize connection delays.

OptimizeForLongConnections | optimizeForLongConnections2

Sort a list of EndpointPair objects to optimize for long connections.


The HostNameSortOptions enumeration affects how a list of EndpointPair objects are sorted.

Given an array of sorted address pairs, the None value returns a sorted list ordering the EndpointPair entries such that pairs with least tried source and destination addresses are prioritized over pairs whose addresses have been tried before and were unsuccessful. The goal is to minimize the connection establishment delay by trying EndpointPair entries with unique addresses first. This might result in less efficient address pairs to be preferred over efficient ones when considering network transfer speeds for long running connections, but that is considered less important than minimizing connection delays for short connections.

For example, if EndpointPair objects can have source addresses of S1 or S2 and destination addresses of D1 or D2, then by default if S1+D1 is the first EndpointPair tried and the connection fails, then S2+D2 is the second pair that would be tried. If the S1+D1 connection fails, the problem might be with either S1 or D1. So the safest option to minimize connection establishment delays would be to try S2+D2 when S1+D1 fails. For activities such as web browsing where speed of getting a connection established dominates, that is most likely the behavior you want.

However if the application is streaming media for a long time, you might be willing to accept a few initial failed connection attempts until you find a more efficient path for transferring data. That would use a different order for sorting. The OptimizeForLongConnections enumeration value would be used for this case. With this setting if S1+D1 fails, then S1+D2 or S2+D1 would be tried next.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::Networking [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8


Windows::Networking [C++]





See also

DatagramSocket.GetEndpointPairsAsync(HostName, String, HostNameSortOptions)