Example #1
0
        /// <summary>
        /// 读取指定字节数据
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="pos"></param>
        /// <param name="size"></param>
        private void AsyncRead(IoBuffer buffer, int pos, int size)
        {
            if (_isFree)
            {
                return;
            }
            _readSize     = pos;
            _waitReadSize = size;

            try
            {
                NetworkStream stream = _tcp.GetStream();
                stream.BeginRead(buffer.array, _readSize, _waitReadSize - _readSize, new AsyncCallback(DoAsyncRead), buffer);
            }
            catch (Exception ex)
            {
                OnException(ex);
            }
        }
Example #2
0
 public NetSession()
 {
     _headBuf = new IoBuffer(32);
 }
Example #3
0
        private void init(int size)
        {
            int n = size / IoBuffer.BLOCK_SIZE + ((size % IoBuffer.BLOCK_SIZE > 0) ? 1 : 0);

            _buffer = new IoBuffer(n * IoBuffer.BLOCK_SIZE);
        }