Currently we sort all of the Hosts we have. If a new host comes in, the list gets sorted again and the worst host gets dropped.
The sorting works like this:
We first check if the last connection failed or succeeded. If one succeeded and the other failed, the one with the failed connection gets sorted down and ultimately removed from the list if it loses against everyone.
If that check didn't show a difference, we check both hosts, if they are decent Phex' (high uptime). If one is a decent Phex host and the other one isn't, the decent Phex host wins and the other gets sorted down.
After that we compare the daily uptime and if that doesn't bring a difference, the time we last connected sucessfully.
If there is no difference with that we simply compare the GUID (close to random...).
In one sentence: If we have enough decent Phex hosts, Phex always prefers starting a connection to a decent Phex (we'll likely have to adapt this once there are more Phex' in the network, but in the current situation it's optimal). Phex does no preferencing for incoming connections.
->
https://phex.svn.sourceforge.net/svn...omparator.java
I smiled happily when I saw this algorithm for the first time, since it is so simple, yet extremely efficient.