示例#1
0
        public void HandleAccepted(IAsyncResult ar)
        {
            if (!bRunning)
            {
                return;
            }
            try
            {
                Socket socket = (Socket)ar.AsyncState;

                //方法参考:http://msdn.microsoft.com/zh-cn/library/system.net.sockets.socket.endreceive.aspx
                if (socket != null)
                {
                    var       client   = socket.EndAccept(ar);
                    IFFSocket ffsocket = new FFScoketAsync(m_oSocketCtrl.ForkSelf(), client);
                    ffsocket.AsyncRecv();
                    FFLog.Info(string.Format("scoket: handleAccepted ip:{0}", ffsocket.GetIP()));
                }
            }
            catch (Exception ex)
            {
                FFLog.Error("scoket: handleAccepted Error " + ex.Message);
            }

            if (bRunning)
            {
                m_oSocket.BeginAccept(new AsyncCallback(HandleAccepted), m_oSocket);
            }
        }
示例#2
0
        public bool InitPool(string host, int nThreadNum)
        {
            m_dbForSync = new MysqlOps();
            if (!m_dbForSync.Connect(host))
            {
                FFLog.Error(string.Format("DbMgr::connectDB failed<{0}>", m_dbForSync.ErrorMsg()));
                m_dbForSync = null;
                return(false);
            }
            m_dbPool = new DBConnectionInfo[nThreadNum];
            for (int i = 0; i < nThreadNum; ++i)
            {
                MysqlOps db = new MysqlOps();
                if (!db.Connect(host))
                {
                    FFLog.Error(string.Format("DbMgr::connectDB failed<{0}>", db.ErrorMsg()));
                    return(false);
                }

                m_dbPool[i] = new DBConnectionInfo()
                {
                    tq = new TaskQueue(),
                    db = db
                };
                m_dbPool[i].tq.Run();
            }
            FFLog.Info(string.Format("DbMgr::connectDB host<{0}>,num<{1}>", host, nThreadNum));
            return(true);
        }
示例#3
0
文件: main.cs 项目: xcschina/h2engine
 static public void Theout()
 {
     FFLog.Trace(string.Format("theout! {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()));
     FFLog.Debug("AAAAAAAAAAAAAAA1");
     FFLog.Trace("AAAAAAAAAAAAAAA2");
     FFLog.Info("AAAAAAAAAAAAAAA3");
     FFLog.Warning("AAAAAAAAAAAAAAA4");
     FFLog.Error("AAAAAAAAAAAAAAA5");
 }
示例#4
0
 public bool cleanup()
 {
     if (m_dbForSync == null)
     {
         return(true);
     }
     FFLog.Info("DbMgr::stop begin...");
     for (int i = 0; i < m_dbPool.Length; ++i)
     {
         m_dbPool[i].tq.Stop();
         m_dbPool[i].db.Close();
     }
     FFLog.Info("DbMgr::stop end");
     return(true);
 }