Exemplo n.º 1
0
        // create a new kcp control object, 'conv' must equal in two endpoint
        // from the same connection.
        public KCP(UInt32 conv_, Action <byte[], int> output_)
        {
            conv    = conv_;
            snd_wnd = IKCP_WND_SND;
            rcv_wnd = IKCP_WND_RCV;
            rmt_wnd = IKCP_WND_RCV;
            mtu     = IKCP_MTU_DEF;
            mss     = mtu - IKCP_OVERHEAD;

            rx_rto    = IKCP_RTO_DEF;
            rx_minrto = IKCP_RTO_MIN;
            interval  = IKCP_INTERVAL;
            ts_flush  = IKCP_INTERVAL;
            ssthresh  = IKCP_THRESH_INIT;
            dead_link = IKCP_DEADLINK;
            buffer    = new byte[(mtu + IKCP_OVERHEAD) * 3];
            output    = output_;

            //创建报文包对象池
            m_oSegmentPool = new ThreadQueue <Segment>();
            m_oSegmentPool.Create();

            //内存池
            m_oMemPool = new MemPool();
            m_oMemPool.Create();

            //
        }
Exemplo n.º 2
0
        //创建
        public void Create()
        {
            m_dicMemPool = new Dictionary <int, ThreadQueue <ByteData> >();
            ThreadQueue <ByteData> threadQueue = null;


            for (int nPower = MIN_SIZE; nPower <= MAX_SIZE; nPower = nPower << 1)
            {
                threadQueue = new ThreadQueue <ByteData>();
                threadQueue.Create();
                m_dicMemPool.Add(nPower, threadQueue);
            }
        }
Exemplo n.º 3
0
        //创建
        public bool Create()
        {
            m_oMemPool = new MemPool();
            m_oMemPool.Create();

            m_oDataQueue = new ThreadQueue <ByteData>();
            m_oDataQueue.Create();
            m_oRecycleQueue = new ThreadQueue <ByteData>();
            m_oRecycleQueue.Create();


            return(true);
        }