Пример #1
0
 protected void triggerOnReceived(ReceiveVO receiveVO, int bytesReceived)
 {
     if (this.OnReceived != null)
     {
         this.OnReceived(this, receiveVO.socket, AbstractTcpSocket.trimmedBytes(receiveVO.bytes, bytesReceived));
     }
 }
        protected override void onReceived(IAsyncResult ar)
        {
            ReceiveVO receiveVO = (ReceiveVO)ar.AsyncState;
            int       num       = 0;

            try
            {
                num = receiveVO.socket.EndReceive(ar);
            }
            catch (SocketException)
            {
            }
            if (num == 0)
            {
                if (receiveVO.socket.Connected)
                {
                    this.removeClient(receiveVO.socket);
                    return;
                }
            }
            else
            {
                string text = AbstractTcpSocket.keyForEndPoint((IPEndPoint)receiveVO.socket.RemoteEndPoint);
                this._logger.Debug(string.Concat(new object[]
                {
                    "Server received ",
                    num,
                    " bytes from ",
                    text
                }));
                base.triggerOnReceived(receiveVO, num);
                base.receive(receiveVO);
            }
        }
Пример #3
0
 protected void receive(ReceiveVO receiveVO)
 {
     receiveVO.socket.BeginReceive(receiveVO.bytes, 0, receiveVO.bytes.Length, SocketFlags.None, new AsyncCallback(this.onReceived), receiveVO);
 }