Beispiel #1
0
    byte[] createHeader()
    {
        string headerChannel = CHANNEL.Length + CHANNEL;

        byte[] headerChannelBytes = new ASCIIEncoding().GetBytes(headerChannel);

        byte[] headerBytes = new byte[headerChannelBytes.Length + 1];
        headerChannelBytes.CopyTo(headerBytes, 1);
        headerBytes[0] = SENDER;
        return(headerBytes);
    }
Beispiel #2
0
        /// <summary>
        /// Build a TCP/IP command to send to the server.
        /// </summary>
        private byte[] BuildTcpIpCommand(string text)
        {
            byte[] command = new ASCIIEncoding().GetBytes(text + "\n");

            byte[] flags = new byte[4] {
                0x54, 0x20, 0x20, 0x20
            };
            int length = flags.Length + command.Length;// + _consoleToken.Length

            byte[] lengthBE = System.BitConverter.GetBytes(SVSEUtility.SwapEndian((uint)length));
            byte[] data     = new byte[length + lengthBE.Length];
            int    offset   = 0;

            lengthBE.CopyTo(data, offset); offset += lengthBE.Length;
            flags.CopyTo(data, offset); offset    += flags.Length;
            command.CopyTo(data, offset);

            return(data);
        }