'Create a new Connection object, using the given OpenSSL.SSL.Context
instance and socket.
:param context: An SSL Context to use for this connection
:param socket: The socket to use for transport layer'

def __init__(self, context, socket=None):

    if (not isinstance(context, Context)):
        raise TypeError('context    must    be    a    Context    instance')
    ssl = _lib.SSL_new(context._context)
    self._ssl = _ffi.gc(ssl, _lib.SSL_free)
    self._context = context
    self._npn_advertise_callback_args = None
    self._npn_select_callback_args = None
    self._alpn_select_callback_args = None
    self._reverse_mapping[self._ssl] = self
    if (socket is None):
        self._socket = None
        self._into_ssl = _lib.BIO_new(_lib.BIO_s_mem())
        self._from_ssl = _lib.BIO_new(_lib.BIO_s_mem())
        if ((self._into_ssl == _ffi.NULL) or (self._from_ssl == _ffi.NULL)):
            _raise_current_error()
        _lib.SSL_set_bio(self._ssl, self._into_ssl, self._from_ssl)
    else:
        self._into_ssl = None
        self._from_ssl = None
        self._socket = socket
        set_result = _lib.SSL_set_fd(self._ssl, _asFileDescriptor(self._socket))
        if (not set_result):
            _raise_current_error()
