using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.Net.Sockets;using System.Threading;using System.IO; namespace RSI_MONITORING{abstract class Comm{protected int port;protected bool type; //true is tcp, false is udp public Comm(){} protected void beginByteLoop(ref TcpClient client, int sleepTime){NetworkStream ns = client.GetStream();BinaryReader reader = new BinaryReader(ns, Encoding.ASCII);FileStream dataFile = new FileStream("C:\\results.dat", FileMode.Append);StreamWriter writer = new StreamWriter(dataFile);System.Collections.ArrayList buffer = new System.Collections.ArrayList();byte myByte;while (true){try{ myByte = reader.ReadByte(); }catch (EndOfStreamException e){Console.WriteLine(e);Console.WriteLine("End of stream");break;}buffer.Add(myByte);if (ns.DataAvailable == false){byte[] convertedBuffer = new byte[buffer.Count];buffer.CopyTo(convertedBuffer);writer.WriteLine(Encoding.ASCII.GetString(convertedBuffer));Console.WriteLine(Encoding.ASCII.GetString(convertedBuffer));}}writer.Close();}}}