public void StartServer(string host, int port, int maxServerCount) { this.port = port.ToString(); this.ip = host; _serverListener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _clientPool = new IndexObjectPool <Connection>(maxServerCount); _frameList = new List <byte[]>(); Listener.NoDelay = true; timer = new Timer(100); timer.AutoReset = true; timer.Elapsed += SendStepAll; timer.Enabled = true; Listener.Bind(new IPEndPoint(IPAddress.Parse(host), port)); Listener.Listen(maxServerCount); Listener.BeginAccept(AcceptCallBack, Listener); _stepMessage = new byte[maxServerCount][]; // framSize = 0; //for (int i = 0; i < _stepMessage.Length; i++) //{ // _stepMessage[i] = new byte[framSize]; //} //ClientPool.Clear(); ServerLog.LogServer("服务器启动成功", 0); }
public FightServer(string host, int port, int maxServerCount) { this.IP = host; this.Port = port; this._maxConnectNum = maxServerCount; _clientPool = new IndexObjectPool <Connection>(this._maxConnectNum); }