Returns (host, port) with an integer port from the specified address
    string. (None, None) is returned if the address is invalid.

def split_address(address):
    """
    Returns (host, port) with an integer port from the specified address
    string. (None, None) is returned if the address is invalid.
    """
    invalid = None, None

    if not address and address != 0:
        return invalid

    components = str(address).split(':')
    if len(components) > 2:
        return invalid

    if components[0] and not valid_hostname(components[0]):
        return invalid

    if len(components) == 2 and not valid_port(components[1]):
        return invalid

    if len(components) == 1:
        components.insert(0 if valid_port(components[0]) else 1, None)

    host, port = components
    port = int(port) if port else None

    return host, port