コード例 #1
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();
            }
        }