pub fn write_frame(
w: &mut impl Write,
msg_type: u8,
payload: &[u8],
) -> Result<(), Error>Expand description
Write a binary frame: [u32 BE length][u8 type][payload].
Assembles the header + payload into a single buffer so that the entire
frame is sent in one write_all call. This avoids multiple small TCP
segments when TCP_NODELAY is enabled.