コード例 #1
0
        public bool Handshake(PacketGenerator gs)
        {
            int nameLength = (int)gs.ReadByte();

            if (gs.GetLength() < 49 + nameLength)
            {
#if DEBUG
                Console.WriteLine("Invalid namelength! Corrupted packet?");
#endif
                return(false);
            }

            string name = gs.ReadString(nameLength);
            gs.SeekIndex(8); //reservedBytes
            byte[] infoHash = gs.ReadByteArray(20);
            string peerID   = gs.ReadString(20);

            bool HanshakeSuccess = infoHash.SequenceEqual(this.Infohash);

            return(HanshakeSuccess);
        }