/// <summary> /// Transform a text file(given as a stream). /// </summary> /// <param name="fileyo"></param> /// <returns>Representation of text file separated into pieces less than 1024 bytes long</returns> public static TextTransformCollection PrepareCollectionFromLargeText(System.IO.Stream fileyo) { byte[] q = new byte[900]; List <byte[]> tik = new List <byte[]>(); TextTransformCollection e = new TextTransformCollection(); string funny; int w = 0; while (fileyo.Position > fileyo.Length) { if (fileyo.Length - (fileyo.Position + 900) >= 0) { fileyo.Read(q, 0, 900); funny = System.Text.Encoding.ASCII.GetChars(q).ToString(); } else { fileyo.Read(q, 0, (int)(fileyo.Length - fileyo.Position)); funny = System.Text.Encoding.ASCII.GetChars(q).ToString(); //replace the nulls on the string with spaces int y = funny.IndexOf('\0'); } e.Add(new TextTransformActor(funny, w)); } return(e); }
/// <summary> /// Create new client with the target IP address as a goal /// </summary> /// <remarks> /// Please put this in a try-catch block, if you use it right Sam, you should be able to force the client to show a proper error message and demand that the user enter a new IPaddress</remarks> /// <param name="target">the IP address of the target server.</param> public ClientForSam(System.Net.IPAddress target) { thingy = new Queue <TextTransformActor>(); //intialize the text transform collection into a non server profile queue = new TextTransformCollection(false); this.server = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.IPv4); this.server.Connect(new System.Net.IPEndPoint(target, 6000)); }