static void Main(string[] args)
        {
            TcpServiceConfig config = new TcpServiceConfig();

            config.ReceviceBuffer        = ReceiveBuffer;
            config.SendBuffer            = ReceiveBuffer;
            config.SendCount             = 10;
            config.MaxConnectionCount    = MaxConnectionCount;
            config.UpdateSessionIntval   = 50;
            config.SessionReceiveTimeout = 0;// 30 * 1000;

            config.MessageFactoryAssemblyName = "NetService";
            config.MessageFactoryTypeName     = "NetService.Message.SimpleBinaryMessageFactory";

            service = new TcpService(config);

            service.ConnectionEvent += new SessionConnectionEvent(ConnectionCallback);
            service.CloseEvent      += new SessionCloseEvent(CloseCallback);
            service.ReceiveEvent    += new SessionReceiveEvent(ReceiveCallback);
            service.MessageEvent    += new SessionMessageEvent(MesssageCallback);

            server = new ChatServer(service);

            service.Run();
            service.StartListener(IPString, Port, Backlog);

            Console.WriteLine("starting server!");

            int update = Environment.TickCount;

            while (true)
            {
                System.Threading.Thread.Sleep(50);
                ConsoleKeyInfo key = Console.ReadKey(true);
                if (key.KeyChar == 'q')
                {
                    break;
                }
                if (Environment.TickCount - update > 5000)
                {
                    Console.WriteLine(service.ToString());
                    update = Environment.TickCount;
                }
            }

            service.Stop();
        }
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                return;
            }

            TcpServiceConfig config = new TcpServiceConfig();

            config.ReceviceBuffer             = ReceiveBuffer;
            config.SendBuffer                 = ReceiveBuffer;
            config.SendCount                  = 10;
            config.MaxConnectionCount         = MaxConnectionCount;
            config.UpdateSessionIntval        = 50;
            config.SessionReceiveTimeout      = 30 * 1000;
            config.MessageFactoryAssemblyName = "NetService";
            config.MessageFactoryTypeName     = "NetService.Message.SimpleBinaryMessageFactory";

            service = new TcpService(config);
            service.ConnectionEvent += new SessionConnectionEvent(ConnectionCallback);
            service.CloseEvent      += new SessionCloseEvent(CloseCallback);
            service.ReceiveEvent    += new SessionReceiveEvent(ReceiveCallback);
            service.MessageEvent    += new SessionMessageEvent(MesssageCallback);


            client         = new ChatClient(service);
            client.Account = args[0];

            service.Run();

            service.StartConnect(IPString, Port, 1000, 0, null);

            Console.WriteLine("starting client");

            while (true)
            {
                string msg = Console.ReadLine();
                if (msg == "quit")
                {
                    break;
                }
                client.SendChat(msg);
            }
            service.Stop();
        }