Esempio n. 1
0
    public void DoIncoming()
    {
        //lock (Socket_)
        //{
        if (!Socket_.Connected)
        {
            return;
        }
        if (Socket_.Poll(0, System.Net.Sockets.SelectMode.SelectRead))
        {
            try
            {
                int recved = Socket_.Receive(IncomingBuffer_.Memory, IncomingBuffer_.WrPtr(), IncomingBuffer_.Space, System.Net.Sockets.SocketFlags.None);
                IncomingBuffer_.WrPtr(recved);
                TotalIncoming_ += recved;
                // ClientLog.Instance.LogError("Incoming once");
            }
            catch (System.Net.Sockets.SocketException se)
            {
                ClientLog.Instance.Log("Exception at DoIncoming" + se.ErrorCode);
                LastError_ = se.ErrorCode;
            }
        }
        //}

        //lock (IncomingBuffer_)
        //{
        //if (RecvBuffer_.Length != 0)
        //{
        //    //解压
        //    RecvBuffer_.Decompression(IncomingBuffer_);

        //}
        //}
    }
Esempio n. 2
0
    public bool Reset()
    {
        if (!IsWorking_)
        {
            return(true);
        }

        bool hasData = false;

        while (IsConneted && LastError == 0)
        {
            if (Socket_.Poll(0, System.Net.Sockets.SelectMode.SelectRead))
            {
                try
                {
                    if (0 >= Socket_.Receive(IncomingBuffer_.Memory, IncomingBuffer_.WrPtr(), IncomingBuffer_.Space, System.Net.Sockets.SocketFlags.None))
                    {
                        break;
                    }
                    else
                    {
                        hasData = true;
                    }
                }
                catch (System.Net.Sockets.SocketException se)
                {
                    ClientLog.Instance.Log("Exception at Reset" + se.ErrorCode);
                    LastError_ = se.ErrorCode;
                    break;
                }
            }
            else
            {
                break;
            }
        }
        IncomingBuffer_.Reset();
        OutgoingBuffer_.Reset();
        return(hasData);
    }