Example #1
0
        /// <summary>
        /// Attaches as a SSL channel with client auth.
        /// </summary>
        /// <param name="certificateValidationCallback"></param>
        protected Promise <ISockNetChannel> AttachAsSslClient(RemoteCertificateValidationCallback certificateValidationCallback)
        {
            stream = new NetworkStream(Socket, true);

            EnableClientSsl(certificateValidationCallback);

            return((attachPromiseFulfiller = new Promise <ISockNetChannel>().CreateFulfiller()).Promise);
        }
Example #2
0
        /// <summary>
        /// Attaches as a SSL channel with client auth.
        /// </summary>
        /// <param name="certificateValidationCallback"></param>
        protected Promise <ISockNetChannel> AttachAsSslServer(RemoteCertificateValidationCallback certificateValidationCallback, X509Certificate serverCert)
        {
            stream = new NetworkStream(Socket, true);

            EnableServerSsl(certificateValidationCallback, serverCert);

            return((attachPromiseFulfiller = new Promise <ISockNetChannel>().CreateFulfiller()).Promise);
        }
Example #3
0
        /// <summary>
        /// Attaches as a non-ssl channel.
        /// </summary>
        protected Promise <ISockNetChannel> Attach()
        {
            stream = new NetworkStream(Socket, true);

            SockNetLogger.Log(SockNetLogger.LogLevel.DEBUG, this, "Reading data from [{0}]...", RemoteEndpoint);

            PooledObject <byte[]> buffer = bufferPool.Borrow();

            buffer.RefCount.Increment();

            receiveState = new ReceiveState()
            {
                buffer = buffer, offset = 0, length = buffer.Value.Length
            };

            canRead = true;

            currentReadResult = stream.BeginRead(buffer.Value, 0, buffer.Value.Length, new AsyncCallback(ReceiveCallback), null);

            return((attachPromiseFulfiller = new Promise <ISockNetChannel>(this).CreateFulfiller()).Promise);
        }