Binds the given socket to the given interface.

    :param socket.socket sock:
        The socket to be bound
    :raises OSError:
        If the specified interface isn't found.

def bind_socket(sock, channel='can0'):
    """
    Binds the given socket to the given interface.

    :param socket.socket sock:
        The socket to be bound
    :raises OSError:
        If the specified interface isn't found.
    """
    log.debug('Binding socket to channel=%s', channel)
    if HAS_NATIVE_SUPPORT:
        sock.bind((channel,))
    else:
        # For Python 2.7
        addr = get_addr(sock, channel)
        libc.bind(sock.fileno(), addr, len(addr))
    log.debug('Bound socket.')