public static void SendBytes(TcpClient c, BaseEncode BaseEncode, byte ender, Action <long> action) { //declare variables byte[] bytes = new byte[1024]; var utf = BaseEncode.GetnetworkEncoding(); NetworkStream s = c.GetStream(); c.SendTimeout = 1000; MemoryStream ms = new MemoryStream(utf.data); int x; while ((x = ms.Read(bytes, 0, bytes.Length)) > 0) { if (action != null) { action.Invoke(ms.Position); } s.Write(bytes, 0, x); } s.WriteByte(ender); Console.WriteLine("H=" + BaseEncode.String()); ms.CopyTo(s); }
public ClientMessage(BaseEncode bytes) { var indexes = GetIndexes(bytes, separator1); byte[] new1 = new byte[indexes[0]]; byte[] new2 = new byte[bytes.data.Length - indexes[0]]; Array.ConstrainedCopy(bytes.data, 0, new1, 0, indexes[0]); Array.ConstrainedCopy(bytes.data, indexes[0], new2, 0, new2.Length); var data1 = new BaseEncode(new1); //arguments var data2 = new BaseEncode(new2); //sub-array byte[] src = data2.data; byte[] dst = new byte[src.Length - separator1.Length]; Array.Copy(src, separator1.Length, dst, 0, dst.Length); var data3 = new BaseEncode(dst);//array messagearray = data3; operation = data1.String().Split(separator2)[0]; message = data1.String().Split(separator2)[1]; }