Correctly check that a server has a valid hostname and port