def valid_port(port):
    """
    Returns whether the specified string is a valid port,
    including port 0 (random port).
    """
    try:
        return 0 <= int(port) <= 65535
    except:
        return False