Beispiel #1
0
        static void Main(string[] args)
        {
            if (File.Exists("log.txt"))
            {
                File.Delete("log.txt");
            }

            var fs = File.AppendText("log.txt");

            sockets = new SocketObject[ClientCount + 1];
            Thread th = new Thread(ProcThread);

            UdpLog.SetWriter(s => { fs.WriteLine(s); });

            sockets[0] = new ServerObject();

            for (int i = 1; i < sockets.Length; ++i)
            {
                sockets[i] = new ClientObject();
            }

            start = DateTime.Now;
            th.Start();

            for (int i = 0; i < sockets.Length; ++i)
            {
                sockets[i].Start();
            }

            while (true)
            {
                Console.Clear();

                for (int i = 0; i < sockets[0].connections.Count; ++i)
                {
                    connectionStats(sockets[0].connections[i]);
                }


                Console.WriteLine("-");

                for (int i = 1; i < sockets.Length; ++i)
                {
                    if (sockets[i].connections.Count > 0)
                    {
                        connectionStats(sockets[i].connections[0]);
                    }
                }

                Thread.Sleep(100);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            if(File.Exists("log.txt"))
                File.Delete("log.txt");

            var fs = File.AppendText("log.txt");
            sockets = new SocketObject[ClientCount + 1];
            Thread th = new Thread(ProcThread);
            UdpLog.SetWriter(s => { fs.WriteLine(s); });

            sockets[0] = new ServerObject();

            for (int i = 1; i < sockets.Length; ++i) {
                sockets[i] = new ClientObject();
            }

            start = DateTime.Now;
            th.Start();

            for (int i = 0; i < sockets.Length; ++i) {
                sockets[i].Start();
            }

            while (true) {
                Console.Clear();

                for (int i = 0; i < sockets[0].connections.Count; ++i) {
                    connectionStats(sockets[0].connections[i]);
                }

                Console.WriteLine("-");

                for (int i = 1; i < sockets.Length; ++i) {
                    if (sockets[i].connections.Count > 0) {
                        connectionStats(sockets[i].connections[0]);
                    }
                }

                Thread.Sleep(100);
            }
        }