Example #1
0
        /// <summary>
        /// 启动
        /// </summary>
        /// <returns></returns>
        public bool Start()
        {
            bool ret = false;

            if (_CurServer != null)
            {
                return(ret);
            }


            //加载服务器配置
            SuperServerConfig ServerConfig = (SuperServerConfig)System.Configuration.ConfigurationManager.GetSection("SuperServerConfig");

            //IPAddress ip = IPAddress.Parse(ServerConfig.IP);
            //IPEndPoint ipe = new IPEndPoint(ip, ServerConfig.Port);

            //AsyncServer server = new AsyncServer(100, 1024);

            //server.Init();

            //server.Start(ipe);

            _CurServer = new SuperServer(ServerConfig);

            _CurServer.Start();


            return(ret);
        }
Example #2
0
        public TcpServer(SuperServerConfig config)
        {
            //if (config == null)
            //    return;
            //_NumConnectedSockets = 0;
            //IPAddress ip = IPAddress.Parse(config.IP);
            //_Ipe = new IPEndPoint(ip, config.Port);
            //_NumConnections = config.NumConnections;
            //_ReceiveBufferSize = config.ReceiveBufferSize;

            //_BufferPool = new BufferManager(_ReceiveBufferSize * _NumConnections * opsToPreAlloc,
            //    _ReceiveBufferSize);

            //_MaxNumberAcceptedClients = new Semaphore(_NumConnections, _NumConnections);
        }
Example #3
0
        public SuperServer(SuperServerConfig config)
        {
            if (config == null)
            {
                return;
            }
            _NumConnectedSockets = 0;
            _TotalBytesRead      = 0;
            IPAddress ip = IPAddress.Parse(config.IP);

            _Ipe               = new IPEndPoint(ip, config.Port);
            _NumConnections    = config.NumConnections;
            _ReceiveBufferSize = config.ReceiveBufferSize;

            _ReadWritePool = new SocketAsyncEventArgsPool(config.NumConnections);

            _BufferPool = new BufferManager(_ReceiveBufferSize * _NumConnections * opsToPreAlloc,
                                            _ReceiveBufferSize);

            _MaxNumberAcceptedClients = new Semaphore(_NumConnections, _NumConnections);
        }