public static int Read(byte[] buf, int c, XmlMessage xm)
{
xm.MessageVersionNumber = buf[c++];
xm.AckNumber = BitConverter.ToUInt16(buf, c);
c += 2;
xm.Time = new DateTime(1970, 1, 1).AddMilliseconds(BitConverter.ToUInt64(
new byte[] { buf[c++], buf[c++], buf[c++], buf[c++], buf[c++], buf[c++], 0, 0 }, 0));
xm.SubType = (XmlMessageSubTypeEnum)buf[c++];
xm.SequenceNumber = BitConverter.ToUInt16(buf, c);
c += 2;
xm.Length = BitConverter.ToUInt16(buf, c);
c += 2;
xm.Text = Encoding.ASCII.GetString(buf, c, xm.Length).Trim('\0'); // null terminated, sometimes?
c += xm.Length;
return c;
}