Esempio n. 1
0
        public void Connect(EndPoint remoteEndPoint)
        {
            if (isDisposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            var e       = m_SaeaManager.Pop();
            var isAsync = false;

            try
            {
                e.RemoteEndPoint = remoteEndPoint;
                e.SetBuffer(e.Offset, 0);
                e.UserToken = this;
                isAsync     = m_Socket.ConnectAsync(e);
            }
            catch (System.Exception)
            {
                m_SaeaManager.Push(e);
                m_Handler.OnBegin(this, false);
                isAsync = true;
            }
            finally
            {
                if (!isAsync)
                {
                    ProcessConnect(e);
                }
            }
        }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            if (!m_IsOpen)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            m_Saeas.ForEach(x => m_SaeaManager.Push(x));
            m_Saeas.Clear();

            m_Capacity    = 0;
            m_Position    = 0;
            m_Length      = 0;
            m_CurPosition = 0;
            m_CurIdx      = 0;
            m_IsOpen      = false;
        }