public override UInt16 Write(Byte[] buf, UInt16 offset, int len) { if (len >= offset + 2) { NetPacketHeader.HtonUInt16(buf, offset, (UInt16)m_Vlue); return(2); } return(0); }
protected UInt16 WriteArrayHead(Byte[] buf, UInt16 offset) { if (m_bBigArray) { NetPacketHeader.HtonUInt16(buf, offset, m_nLen); return(2); } else { buf[offset] = (Byte)m_nLen; } return(1); }
public override UInt16 Write(Byte[] buf, UInt16 offset, int len) { UInt16 nResult = 0; if (null != m_Vlue) { String str = (string)m_Vlue; Byte[] strbuf = Encoding.UTF8.GetBytes(str); NetPacketHeader.HtonUInt16(buf, offset, (ushort)strbuf.Length); Array.ConstrainedCopy(strbuf, 0, buf, offset + 2, strbuf.Length); nResult = (UInt16)(strbuf.Length + 2); } return(nResult); }
public static UInt16 HtonString(Byte[] buf, int offset, string vl) { UInt16 nResult = 0; if (null != vl) { String str = vl; Byte[] strbuf = Encoding.UTF8.GetBytes(str); NetPacketHeader.HtonUInt16(buf, offset, (ushort)strbuf.Length); Array.ConstrainedCopy(strbuf, 0, buf, offset + 2, strbuf.Length); nResult = (UInt16)(strbuf.Length + 2); } return(nResult); }
public override UInt16 Write(Byte[] buf, UInt16 offset, int len) { UInt16 nResult = offset; UInt16 n = WriteArrayHead(buf, offset); if (len > offset + n + m_nLen * 2) { offset += n; for (n = 0; n < m_nLen; ++n) { NetPacketHeader.HtonUInt16(buf, offset, (UInt16)m_Vlue); offset += 2; } return((UInt16)(offset - nResult)); } return(0); }