public void Write(string data) { byte[] bytes = GetArrotOfBytes(data); bytes = ByteStuffing.Encode(bytes); Int32 count = bytes.Length; senderPort.Write(bytes, 0, count); //for (int offset = 0; offset < count; offset++) //{ //} }
public string Read() { byte[] buffer = new byte[BUFFER_SIZE]; Int32 offset = 0; Int32 count = BUFFER_SIZE; int readbytes; try { readbytes = receiverPort.Read(buffer, offset, count); buffer = ByteStuffing.Decode(buffer); } catch (TimeoutException) { } return(Encoding.UTF8.GetString(buffer)); }