def parse_address(address):
    """Parse and address on the format host:port.

    Returns a tuple (host, port). Raises ValueError if format is
    invalid or port is not an integer or out of range.
    """
    words = address.split(':')
    if len(words) != 2:
        raise ValueError('address must contain exactly one colon')
    host, port = words
    try:
        port = int(port)
    except ValueError:
        raise ValueError('port number must be an integer')
    if not 0 < port < 2 ** 16:
        raise ValueError('port number out of range')
    return host, port
