Added check for valid InetAddress.