protected virtual void OnCompleted(SecureSocketEventArgs e)
 {
     if (e == null)
     {
         return;
     }
     if (Completed != null)
     {
         Completed(m_SecureSocket, e);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Sends data asynchronously to a remote host
        /// </summary>
        /// <param name="e">The SecureSocketEventArgs object to use for this asynchronous socket operation</param>
        /// <returns></returns>
        public bool SendAsync(SecureSocketEventArgs e)
        {
            if (m_Disposed == true)
            {
                throw new ObjectDisposedException("m_SecureSocket");
            }

            e.SetSecureSocket(this);
            List <Record> listOfRecords = m_Bus.HandleDataToBeSent(e.Buffer, e.Offset, e.Count);

            byte[] data = Records.Merge(listOfRecords);
            e.SetBufferInternal(data, 0, data.Length);
            bool result = m_InternalSocket.SendAsync(e.InternalEventArgs);

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Connects asynchronously to a remote host
        /// </summary>
        /// <param name="e">The SecureSocketEventArgs object to use for this asynchronous socket operation</param>
        /// <returns>Type: System.Boolean
        /// Returns true if the I/O is pending, false if the operation completed synchronously</returns>
        public bool ConnectAsync(SecureSocketEventArgs e)
        {
            if (m_Disposed == true)
            {
                throw new ObjectDisposedException("m_SecureSocket");
            }

            if (m_InternalSocket.Connected)
            {
                return(true);
            }
            m_ConnectType = 1;
            e.SetSecureSocket(this);
            bool result = m_InternalSocket.ConnectAsync(e.InternalEventArgs);

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Receive data asynchronously from a remote host
        /// </summary>
        /// <param name="e">The SslSocketArgs object to use for this asynchronous socket operation</param>
        /// <returns>Type: System.Boolean
        /// Returns true if the I/O is pending, false if the operation completed synchronously</returns>
        public bool ReceiveAsync(SecureSocketEventArgs e)
        {
            if (m_Disposed)
            {
                throw new ObjectDisposedException("m_SecureSocket");
            }

            int available = e.CheckQueues(m_Bus);

            if (available != 0)
            {
                e.RaiseCompletedForReceive(available);
                return(true);
            }
            else
            {
                e.SetSecureSocket(this);
                e.SetBufferForReceive();
                bool result = m_InternalSocket.ReceiveAsync(e.InternalEventArgs);
                return(result);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initiates a handshake with a remote host
        /// </summary>
        /// <param name="e">The SslSocketArgs object to use for this asynchronous socket operation</param>
        public bool SecureConnectAsync(SecureSocketEventArgs e)
        {
            if (m_Disposed == true)
            {
                throw new ObjectDisposedException("m_SecureSocket");
            }

            bool result;

            m_ConnectType = 2;
            if (!m_InternalSocket.Connected)
            {
                m_IsSecureConnected = false;
            }

            if (m_IsSecureConnected)
            {
                return(true);
            }

            if (m_InternalSocket.Connected)
            {
                e.SetSecureSocket(this);
                m_Bus = new Bus();
                List <Record> listOfRecords = m_Bus.StartHandshake();
                byte[]        data          = Records.Merge(listOfRecords);
                Console.WriteLine("Internal Socket is connected. " + BitConverter.ToString(data));
                e.SetBufferInternal(data, 0, data.Length);
                result = m_InternalSocket.SendAsync(e.InternalEventArgs);
            }
            else
            {
                e.SetSecureSocket(this);
                m_Bus  = new Bus();
                result = m_InternalSocket.ConnectAsync(e.InternalEventArgs);
            }
            return(result);
        }