Exemplo n.º 1
0
        public void Dispose()
        {
            this._sendSaePool.Dispose();
            this._sendSaePool = null;
            this._sendSemaphoreSendedClients.Close();
            //this.sendSemaphoreSendedClients.Dispose();
            this._sendSemaphoreSendedClients = null;
            if (this._port > 0)
            {
                this._tcpReceiveBufferManager.Dispose();
                this._tcpReceiveBufferManager = null;
                this._tcpReceiveSaePool.Dispose();
                this._tcpReceiveSaePool = null;
                this._tcpReceiveSemaphoreSendedClients.Close();
                //this.tcpReceiveSemaphoreSendedClients.Dispose();
                this._tcpReceiveSemaphoreSendedClients = null;

                this._udpReceiveBufferManager.Dispose();
                this._udpReceiveBufferManager = null;
                this._udpReceiveSaePool.Dispose();
                this._udpReceiveSaePool = null;
                this._udpReceiveSemaphoreSendedClients.Close();
                //this.udpReceiveSemaphoreSendedClients.Dispose();
                this._udpReceiveSemaphoreSendedClients = null;
            }

            _listenSocketTcp = null;
            _listenSocketUdp = null;
        }
Exemplo n.º 2
0
        public Listen()
        {
            this._port = int.Parse(Utility.AppConfig.GetValue("Port"));
            this._receiveBufferSize = int.Parse(Utility.AppConfig.GetValue("BufferSize")); //1024字节
            this._maxConnect        = int.Parse(Utility.AppConfig.GetValue("MaxConnect"));
            this._log         = bool.Parse(Utility.AppConfig.GetValue("Log"));
            this._sendSaePool = new SAEPool(_maxConnect);
            this._sendSemaphoreSendedClients = new Semaphore(_maxConnect, _maxConnect);
            if (this._port > 0)
            {
                this._tcpReceiveBufferManager          = new BufferManager(_receiveBufferSize * _maxConnect * 2, _receiveBufferSize);
                this._tcpReceiveSaePool                = new SAEPool(_maxConnect);
                this._tcpReceiveSemaphoreSendedClients = new Semaphore(_maxConnect, _maxConnect);
                this._udpReceiveBufferManager          = new BufferManager(_receiveBufferSize * _maxConnect * 2, _receiveBufferSize);
                this._udpReceiveSemaphoreSendedClients = new Semaphore(_maxConnect, _maxConnect);
                this._udpReceiveSaePool                = new SAEPool(_maxConnect);
            }

            this._totalUdpListConnect = 20;
        }