loop until a port is ok