Esempio n. 1
0
        /// <summary>
        /// buffer pool로 IOBuffer 객체를 반납한다.
        /// </summary>
        /// <param name="buf">반납할 IOBuffer 객체.</param>
        static internal void Free(IOBuffer buf)
        {
            if (buf == null)
                return;

            IOSlot slot = m_slots[Interlocked.Increment(ref m_indexFree) & (SLOT_SIZE - 1)];
            slot.GoBackIOBuffer(buf);
        }
Esempio n. 2
0
        public SmartPacket(ushort code)
        {
            m_code = code;
            m_bCRCCheck = false;
            m_bEncrypt = true;

            m_encodedBuf = IOBuffer.Alloc();
            m_dataSize = 0;
        }
Esempio n. 3
0
        /// <summary>
        /// 이 슬롯으로 IOBuffer 객체를 반환한다.
        /// </summary>
        /// <param name="ioBuffer">반환할 IOBuffer 객체.</param>
        internal void GoBackIOBuffer(IOBuffer ioBuffer)
        {
            if (ioBuffer == null)
                return;

            lock (m_stackIOBuffer)
            {
                m_stackIOBuffer.Push(ioBuffer);
            }
        }
Esempio n. 4
0
        public void SetClient(TcpClient tcpClient)
        {
            lock (m_lock)
            {
                m_stream = tcpClient.GetStream();

                if (m_recvBuf != null)
                    m_recvBuf.ReleaseRef();
                m_recvBuf = IOBuffer.Alloc();

                m_tcpClient = tcpClient;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 이 슬롯에서 IOBuffer 객체를 얻는다.<br/>
        /// 남아있는 객체가 없으면 new operation을 통해 관리힙에서 할당받는다.
        /// </summary>
        /// <returns>할당받은 IOBuffer 객체.</returns>
        internal IOBuffer GetIOBuffer()
        {
            IOBuffer buf = null;

            lock (m_stackIOBuffer)
            {
                if (m_stackIOBuffer.Count > 0)
                {
                    buf = m_stackIOBuffer.Pop();
                    buf.AddRef();
                }
            }

            if (buf == null)
                buf = new IOBuffer();

            return buf;
        }
Esempio n. 6
0
        /// <summary>
        /// remote host로 데이터를 보낸다. blocking mode로 동작한다.
        /// </summary>
        /// <param name="data">전송할 데이터</param>
        /// <exception cref="System.IO.IOException">write operation error. 소켓이 끊긴 경우.</exception>
        /// <exception cref="System.ObjectDisposedException">소켓이 끊긴 경우.</exception>
        /// <exception cref="System.ArgumentException">파라미터 data가 유효한 객체가 아닐 경우.</exception>
        public void Write(IOBuffer data)
        {
            //++ blocking mode 시
            m_stream.Write(data.Buffer, 0, data.Size);
            //--

            //++ non-blocking mode 시
            //m_eventWrite.Reset ();
            //m_stream.BeginWrite(data.Buffer, 0, data.Size, m_callbackWrite, m_stream);
            //m_eventWrite.WaitOne();
            //--
        }
Esempio n. 7
0
        /// <summary>
        /// remote host와의 연결을 닫는다.
        /// </summary>
        public void Close()
        {
            lock (m_lock)
            {
                if (m_tcpClient != null)
                {
                    m_tcpClient.Close();
                    m_tcpClient = null;
                }

                if (m_recvBuf != null)
                {
                    m_recvBuf.ReleaseRef();
                    m_recvBuf = null;
                }
            }
        }
Esempio n. 8
0
 /// <summary>
 /// IOBuffer 객체 값을 이 객체 값의 끝에 추가한다. 
 /// </summary>
 /// <param name="buf">추가될 IOBuffer 객체.</param>
 /// <exception cref="System.OverflowException">최대 버퍼크기를 넘어서면 발생한다.</exception>
 public void Append(IOBuffer buf)
 {
     CopyIntoBuffer(buf.Buffer, buf.Size);
 }
Esempio n. 9
0
 public void Dispose()
 {
     m_rawBuf.ReleaseRef();
     m_rawBuf = null;
 }
Esempio n. 10
0
 public ISmartStream()
 {
     m_rawBuf = IOBuffer.Alloc();
 }
Esempio n. 11
0
        public OSmartStream()
        {
            m_rawBuf = IOBuffer.Alloc();
            m_compBuf = IOBuffer.Alloc();

            Clear();
        }
Esempio n. 12
0
 public void Dispose()
 {
     m_encodedBuf.ReleaseRef();
     m_encodedBuf = null;
 }