Beispiel #1
0
        public void addBuff(byte[] buff)
        {
            if (buff == null || buff.Length == 0)
            {
                return;
            }
            RecvBuffer.AddRange(buff);
            if (RecvBuffer.Count <= 2)
            {
                return;
            }
            UInt16 len   = (UInt16)System.Net.IPAddress.HostToNetworkOrder((short)BitConverter.ToUInt16(RecvBuffer.ToArray(), 0));
            int    total = len + 2;

            if (RecvBuffer.Count < total)
            {
                return;
            }
            byte[] tbuff = new byte[len];
            RecvBuffer.CopyTo(2, tbuff, 0, len);
            RecvPacket.BeginRead(tbuff);
            RecvBuffer.RemoveRange(0, total);
        }