Example #1
0
        public static byte[] Handshake(string clientName, byte[] info_hash, string peer_id)
        {
            PacketGenerator rs = new PacketGenerator();

            byte[] reservedBytes = { 0, 0, 0, 0, 0, 0, 0, 0 };

            rs.WriteByte(Convert.ToByte(clientName.Length));
            rs.WriteString(clientName);
            rs.WriteByteArray(reservedBytes);
            rs.WriteByteArray(info_hash);
            rs.WriteString(peer_id);

            return(rs.GetByteArray());
        }