Esempio n. 1
0
        /// <summary>
        /// 启动服务器
        /// </summary>
        public void StartServer(string host, int port)
        {
            listen = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress  ipAddress  = IPAddress.Parse(host);
            IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port);

            listen.Bind(ipEndPoint);
            listen.Listen(maxClient);
            listen.BeginAccept(AcceptCallBack, null);
            Console.WriteLine("服务器启动成功!");
            SessionClientPool.SetMaxSessionClient(maxClient);
        }