public bool AsyncSendMsg(UInt32 msg_id, byte[] datas, IAttachParas attach) { MemoryStream memstream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(memstream); byte[] msg_id_bytes = System.BitConverter.GetBytes(msg_id); Array.Reverse(msg_id_bytes); writer.Write(msg_id_bytes); byte[] attach_datas = null; if (attach != null) { attach_datas = attach.FillNetStream(); } if (attach_datas != null) { byte[] attach_len_bytes = System.BitConverter.GetBytes((UInt16)attach_datas.Length); Array.Reverse(attach_len_bytes); writer.Write(attach_len_bytes); writer.Write(attach_datas); } else { byte[] attach_len_bytes = System.BitConverter.GetBytes((UInt16)0); Array.Reverse(attach_len_bytes); writer.Write(attach_len_bytes); } if (datas != null && datas.Length != 0) { writer.Write(datas); } byte[] out_content; coder.FillNetStream(memstream.ToArray(), out out_content); conn.AsyncSend(out_content); return(true); }