static void DoSend() { String aRequest = String.Empty; String aData = String.Empty; byte[] aDataBytes = null; Int32 aDataLen = 0; Console.Write("Enter Request: "); aRequest = Console.ReadLine(); Console.Write("Include Data? (Y/N) "); aData = Console.ReadLine(); if (aData.ToLower() == "y") { Console.Write("Enter Data: "); aData = Console.ReadLine(); aDataBytes = System.Text.Encoding.ASCII.GetBytes(aData); aDataLen = aDataBytes.Length; } else { aDataBytes = null; aDataLen = 0; } GClient.Submit(ref aRequest, aDataBytes, aDataLen); }
static void DoSendLarge() { String aInput = String.Empty; String aRequest = String.Empty; UInt16 aNumOfBytes = 0; byte aByte = 0; byte[] aByteString = null; byte[] aData = null; Int32 aRepeat; Int32 aInterval; // Get number of bytes to send Console.Write("Enter Size of Request (in bytes): "); aInput = Console.ReadLine(); aNumOfBytes = UInt16.Parse(aInput); if (aNumOfBytes > 0) { aByteString = new byte[aNumOfBytes]; for (UInt16 i = 0; i < (aNumOfBytes); i++) { aByte = (byte)(i % Byte.MaxValue); if (aByte < 33) { aByte = 46; } else if (aByte > 127 && aByte < 160) { aByte = 46; } aByteString[i] = aByte; } aRequest = System.Text.Encoding.GetEncoding(28591).GetString(aByteString); Console.WriteLine(DateTime.Now.TimeOfDay + ": INFO: Request:"); DumpBytes(aByteString, 0, aByteString.Length); } Console.Write("Enter Size of Data (in bytes): "); aNumOfBytes = UInt16.Parse(Console.ReadLine()); if (aNumOfBytes > 0) { aData = new byte[aNumOfBytes]; for (UInt16 i = 0; i < (aNumOfBytes); i++) { aByte = (byte)(i % Byte.MaxValue); if (aByte < 33) { aByte = 46; } else if (aByte > 127 && aByte < 160) { aByte = 46; } aData[i] = aByte; } Console.WriteLine(DateTime.Now.TimeOfDay + ": INFO: Data: "); DumpBytes(aData, 0, aData.Length); } else { aNumOfBytes = 0; } Console.Write("Enter No. of Times to Repeat: "); aRepeat = Int32.Parse(Console.ReadLine()); Console.Write("Enter No. of Interval (in ms): "); aInterval = Int32.Parse(Console.ReadLine()); if (aInterval < 0) { Console.Error.WriteLine("Error: Invalid Interval Size."); return; } for (int i = 0; i < aRepeat; i++) { // Send request message GClient.Submit(ref aRequest, aData, aNumOfBytes); // Sleep Thread.Sleep(aInterval); } }