Beispiel #1
0
        private static void Read(object target)
        {
            TcpClient     client = (TcpClient)target;
            NetworkStream stream = client.GetStream();

            while (true)
            {
                if (!client.Connected)
                {
                    break;
                }
                byte[] read = new byte[client.ReceiveBufferSize];
                int    readInt;
                try
                {
                    readInt = stream.Read(read, 0, read.Length);
                    Crypter c       = new Cryptography.Crypter(new ConfigKeySym());
                    string  decrypt = c.Decrypt(ASCIIEncoding.ASCII.GetString(read).Replace("\0", ""));
                    Console.WriteLine("From server : {0}", decrypt.Replace("\0", ""));
                }
                catch
                {
                    return;
                }
            }
        }
Beispiel #2
0
 private static void Read(object target)
 {
     TcpClient client = (TcpClient)target;
     NetworkStream stream = client.GetStream();
     while (true)
     {
         if (!client.Connected)
             break;
         byte[] read = new byte[client.ReceiveBufferSize]; 
         int readInt;
         try
         {
             readInt = stream.Read(read, 0, read.Length);
             Crypter c = new Cryptography.Crypter(new ConfigKeySym());
             string decrypt = c.Decrypt(ASCIIEncoding.ASCII.GetString(read).Replace("\0", ""));
             Console.WriteLine("From server : {0}", decrypt.Replace("\0", ""));
         }
         catch 
         {
             return;
         }
     }
 }