예제 #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 void HandleAccepted(IAsyncResult ar)
        {
            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_funcRecv, m_funcBroken, m_funcPreSendCheck, client);
                    ffsocket.AsyncRecv();
                    m_oSocket.BeginAccept(new AsyncCallback(HandleAccepted), m_oSocket);
                    FFLog.Trace(string.Format("scoket: handleAccepted ip:{0}", ffsocket.GetIP()));
                }
            }
            catch (Exception ex)
            {
                FFLog.Trace("scoket: handleAccepted Error " + ex.Message);
            }
        }