2. tds. The current code has no packet layer. Each packet is hand-built (if you will): put the token, put the length, put this byte, put these two bytes, put this string, etc. It would be clearer if there were functions like "write_<token>_packet(struct <token>_packet_type* data)". Most packets -- everything except rows -- are quite small and can easily be described by a