static void Main(string[] args)
        {
            string s = " ";
            Packet p = new Packet();

            p.WriteString(s);

            try
            {
                MyReceiver receiver = new MyReceiver();

                var            maxConnect = 1024;
                AsyncIOManager netserver  = new AsyncIOManager(4, receiver, 1024, maxConnect, 512);

                AsyncSocket prototype = AsyncSocket.GetPrototype();
                AsyncSocket.InitUIDAllocator(1, maxConnect);

                Acceptor acceptor = new Acceptor(netserver, prototype, "192.168.0.79", 3210);
                acceptor.Start();

                while (true)
                {
                    // 이 예제는 연결된 클라이언트들에게 2초마다 뭔가를 날려줍니다요~
                    System.Threading.Thread.Sleep(2000);
                    receiver.Process();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                // 1 Gb array
                // byte[] arr = new byte[1024 * 1024 * 1024];
                MyReceiver receiver = new MyReceiver();

                var            maxConnect = 2000;
                AsyncIOManager netserver  = new AsyncIOManager(1, receiver, 1024, maxConnect, 512);

                AsyncSocket prototype = AsyncSocket.GetPrototype();
                AsyncSocket.InitUIDAllocator(1, maxConnect);

                for (int i = 0; i < 10000; i++)
                {
                    netserver.connectSocket(i + 1, prototype.Clone(), "192.168.0.79", 3210);
                    //netserver.connectSocket(i + 1, prototype.Clone(), "192.168.0.90", 9295);
                }

                Console.ReadLine();
                Console.WriteLine(receiver.cnt);
                Console.ReadLine();

                System.Threading.Thread.Sleep(5000);

                int cnt = 1;
                while (true)
                {
                    Packet p = new Packet();

                    int size = 4 + (8 * cnt);

                    p.WriteInt(size);

                    for (int i = 0; i < cnt; ++i)
                    {
                        long d = 1;
                        p.WriteLong(d);
                    }

                    receiver.sinfo.NetSender.PostingSend(receiver.sinfo, p.Position, p.GetBuffer());

                    cnt++;

                    if (cnt > 11)
                    {
                        cnt = 1;
                    }

                    System.Threading.Thread.Sleep(10);
                }

                // Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }