Example #1
0
 /// <summary>
 /// Sends Bytes to the server
 /// </summary>
 /// <param name="bytes"></param>
 public void SendBytes(byte[] bytes)
 {
     if (StreamDebugging.TxStreamDebuggingIsEnabled)
     {
         Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
     }
     if (Client != null)
     {
         Client.SendData(bytes, bytes.Length);
     }
 }
Example #2
0
        /// <summary>
        /// General send method
        /// </summary>
        public void SendText(string text)
        {
            var bytes = Encoding.GetEncoding(28591).GetBytes(text);

            // Check debug level before processing byte array
            if (StreamDebugging.TxStreamDebuggingIsEnabled)
            {
                Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
            }
            if (Client != null)
            {
                Client.SendData(bytes, bytes.Length);
            }
        }
        /// <summary>
        /// Sends Bytes to the server
        /// </summary>
        /// <param name="bytes"></param>
        public void SendBytes(byte[] bytes)
        {
            try
            {
                if (Client != null)
                {
                    if (StreamDebugging.TxStreamDebuggingIsEnabled)
                    {
                        Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
                    }

                    TheStream.Write(bytes, 0, bytes.Length);
                    TheStream.Flush();
                }
            }
            catch
            {
                Debug.Console(1, this, "Stream write failed. Disconnected, closing");
                ClientStatus = SocketStatus.SOCKET_STATUS_BROKEN_REMOTELY;
                HandleConnectionFailure();
            }
        }