예제 #1
0
                public override void nairIptbase(NccpcNao1IptBase iptb)
                {
                    switch ((Nit)iptb.mTypeid)
                    {
                    case Nit.Send:
                    {
                        var ni = (NiSend)iptb;

                        using (var pkw = ni.mPk)
                        {
                            ni.mPk = null;
                            mNw.send(pkw);
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }
        static void Main(string[] args)
        {
            qv("Dbg " + (new System.Diagnostics.StackFrame(0, true)).GetFileName());
            NccpcNw1Cmn.stWsaStartup();

            var mm = new NccpcMemmgr2Mgr();
            //var tm = new NccpcTdMgr2();
            var  cts  = new List <TtCt>();
            var  sv   = new TtSv(mm);
            long ctcc = 0;             //conn cnt;

            if (!mm.create())
            {
                qv("Err mm create fail"); return;
            }
            //if (!tm.create()) { qv("Err tm create fail"); return; }
            //if (!sv.create()) { qv("Err sv create fail"); return; }


            qv("Dbg Ctm1 startup h:" + gHost + " s:" + gServ);
            qv("Dbg key: Q = Quit, ");


            bool bWhile = true;

            while (bWhile)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo k = Console.ReadKey(false);

                    switch (k.Key)
                    {
                    case ConsoleKey.Q:
                        bWhile = false;
                        qv("Dbg quit");
                        break;

                    case ConsoleKey.S:
                    {
                        if (!sv.create())
                        {
                            qv("Err sv.create fail"); break;
                        }
                    }
                    break;

                    case ConsoleKey.C:
                    {
                        for (int tc = 0; tc < gCtmax; tc++)
                        {
                            var ct = new TtCt(ref ctcc);
                            if (!ct.create())
                            {
                                qv("Err Ct.create() fail"); return;
                            }

                            using (var pkw = NccpcNw1Pk2.stAlloc(gPkBfMax))
                            {
                                var pkwlen = pkw.getWritableLen();
                                for (int i = 0; i < pkwlen; i++)
                                {
                                    pkw.wInt8s((sbyte)i);
                                }

                                ct.send(pkw);
                            }

                            cts.Add(ct);

                            //lock (gLockobj) { gTdCnt++; }

                            //Jc1.Tdut.exec(ct.exec);
                        }
                    }
                    break;

                    case ConsoleKey.L:
                    {
                        if (gFlog != null)
                        {
                            qv("Dbg Log off"); gFlog = null;
                        }
                        else
                        {
                            gFlog = new NccpcSflMt1Simple1("Nc1ExNwStress1", 0xffff); qv("Dbg Log on");
                        }
                    }
                    break;
                    }
                }
                else
                {
                    sv.framemove();
                    //if (cts.Count != 0) { qv("Dbg Cts:" + cts.Count + " Ctcc:" + System.Threading.Interlocked.Read(ref TtCt.gCtcc)); }
                    System.Threading.Thread.Sleep(1000);
                }
            }

            foreach (var ct in cts)
            {
                ct.release();
            }

            sv.release();

            mm.release();

            NccpcNw1Cmn.stWsaCleanup();
        }