예제 #1
0
 private static void Sender(Stream writer)
 {
     while (true)
     {
         Console.Write("Local Host>  ");
         string str = StandardIOWrapper.ReadLine() ?? "EXIT";
         if (str.Trim().ToUpper() == "EXIT")
         {
             return;
         }
         Send(writer, str);
     }
 }
예제 #2
0
        private static void Receiver(DataReader reader, CancellationToken token)
        {
            while (true)
            {
                reader.LoadAsync(sizeof(uint)).AsTask(token).Wait();
                byte[] buffer = new byte[reader.ReadInt32()];
                reader.LoadAsync((uint)buffer.Length).AsTask(token).Wait();
                reader.ReadBytes(buffer);

                StandardIOWrapper.WriteLine("Remote Host>  " +
                                            Encoding.ASCII.GetString(buffer));
            }
        }