Beispiel #1
0
        public bool Parse(byte[] recv)
        {
            ushort length = ByteTools.ToUInt16(ByteTools.SubBytes(recv, 0, 2), true);

            if (length != recv.Length)
            {
                return(false);
            }

            byte[] ip   = ByteTools.SubBytes(recv, 3, 4);
            byte[] port = ByteTools.SubBytes(recv, 7, 2);

            IPEndPoint iPEnd = ByteTools.GetIPEndPoint(ip, port);

            TargetServerIP       = iPEnd.Address.ToString();
            TargetServerHostPort = iPEnd.Port.ToString();

            return(true);
        }
        public bool Parse(byte[] recv)
        {
            ushort length = ByteTools.ToUInt16(ByteTools.SubBytes(recv, 0, 2), true);

            //if(recv.Length<length)
            //{
            //    return false;
            //}

            byte[] ip   = ByteTools.SubBytes(recv, 3, 4);
            byte[] port = ByteTools.SubBytes(recv, 7, 2);
            Array.Reverse(port);

            IPEndPoint iPEnd = ByteTools.GetIPEndPoint(ip, port);

            TargetServerIP       = iPEnd.Address.ToString();
            TargetServerHostPort = iPEnd.Port.ToString();

            return(true);
        }