pub fn split_message(
kind: u8,
payload: &[u8],
packet_size: usize,
) -> Vec<Vec<u8>>Expand description
Frame a payload as one or more packets of at most packet_size bytes.
Only the final packet carries the end-of-message bit, which is how the peer knows a login or a statement longer than one packet is complete. The packet id restarts at one for every message, exactly as MS-TDS requires.
Each packet comes back as its own buffer rather than one concatenated block, and that is not a stylistic choice. Over an encrypted connection SQL Server expects one TDS packet per TLS record: give it a record holding two packets and it drops the connection without a word — a live server confirmed it, at exactly the payload size where a second packet appears, and only when encryption was on. Writing each packet separately puts each in its own record, which is what every working TDS client does.