Example #1
0
        static void Main(string[] args)
        {
            //IPAddress[] addressList = Dns.GetHostEntry(Environment.MachineName).AddressList;
            
            int ipPoint = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ipPoint"]);
            string ipBind = System.Configuration.ConfigurationManager.AppSettings["ipBind"];


            server = new TcpServerHost(new TcpServerConfig(ipPoint: ipPoint), new AccreditHandle(), TcpServerLoger.GetInstance);

            server.AcceptSuccess = (x) =>
            {
                Console.WriteLine(string.Format("接入UserToken数:{0}", server.UserTokenCount()));
            };

            IPAddress ipAddress;
            if (ipBind == "*")
            {
                ipAddress = IPAddress.Loopback;
            }
            else
            {
                ipAddress = IPAddress.Parse(ipBind);
            }

            server.StartUp(ipAddress);

            Console.ReadKey();

        }
Example #2
0
        static void Main(string[] args)
        {
            IPAddress[] addressList = Dns.GetHostEntry(Environment.MachineName).AddressList;
            server = new TcpServerHost(new TcpServerConfig(ipPoint:8181), new AccreditHandle(), new TcpServerLoger());

            server.AcceptSuccess = (x) =>
            {
                Console.WriteLine(string.Format("接入UserToken数:{0}", server.UserTokenCount()));
            };
            server.StartUp(IPAddress.Any);


            Console.ReadKey();
        }