Which connected metric spaces are compact