private void SerializeHeader(byte[] buffer, ushort size, ushort command) { HEADER hEADER = new HEADER(size + 5, command); RawSerializer rawSerializer = new RawSerializer(hEADER.GetType(), false); MemoryStream target = new MemoryStream(buffer); int num; rawSerializer.Serialize(hEADER, target, out num); }
private int RecvHeader(ref HEADER header) { try { byte[] buffer = new byte[5]; int result = this._parent.Sock.Receive(buffer); RawSerializer rawSerializer = new RawSerializer(header.GetType(), false); MemoryStream source = new MemoryStream(buffer); rawSerializer.Deserialize <HEADER>(ref header, source); return(result); } catch (Exception) { } return(0); }