Example #1
0
        public TCPSocketTokenPool(int capacity, int sendBufferSize, int reciveBufferSize, TCPConnectPool connPool)
        {
            _TokenPool        = new Queue <TCPSocketToken>(capacity);
            connectPool       = connPool;
            _SendBufferSize   = sendBufferSize;
            _ReciveBufferSize = reciveBufferSize;

            for (int i = 0; i < capacity; ++i)
            {
                _TokenPool.Enqueue(CreatNewToken());
            }
        }
Example #2
0
        public TCPSocketToken(int sendBufferSize, int reciveBufferSize, TCPConnectPool conPool)
        {
            connnectPool = conPool;
            currPackHead = new NetPacketHead(conPool.Packethead);
            byte[] sendBuffer = new byte[sendBufferSize];
            sendSAEA = new SocketAsyncEventArgs();
            sendSAEA.SetBuffer(sendBuffer, 0, sendBuffer.Length);
            sendSAEA.UserToken  = this;
            sendSAEA.Completed += new EventHandler <SocketAsyncEventArgs>(conPool.OnIOCompleted);

            byte[] reciveBuffer = new byte[reciveBufferSize];
            reciveSAEA = new SocketAsyncEventArgs();
            reciveSAEA.SetBuffer(reciveBuffer, 0, reciveBuffer.Length);
            reciveSAEA.UserToken  = this;
            reciveSAEA.Completed += new EventHandler <SocketAsyncEventArgs>(conPool.OnIOCompleted);
        }