import socket


def ipv4_to_int(ip_address):
    """Converts an IPv4 string to integer

    Parameters
    ----------
    ip_address: str eg. '1.1.1.1'
        The IPv4 string

    Returns
    -------
    integer_ipv4_address: int
        The integer representation of the IPv4 string

    """
    # Check IP address using socket
    try:
        socket.inet_aton(ip_address)
    except socket.error as e:
        raise Exception('Invalid input IP:', e)

    # Split IP address and convert to int
    try:
        ip = ip_address.split('.')
        assert len(ip) == 4
        integer_ipv4_address = 0
        for b in ip:
            b = int(b)
            integer_ipv4_address = (integer_ipv4_address << 8) | b
    except Exception as e:
        raise Exception('Couldn\'t convert IP:', e)
    else:
        return integer_ipv4_address