Reading some x11 protocol code and code was pretty weird by modern standards … like, it’s mostly just writing a struct literally from memory…. Cast that lil struct to a void pointer and write it out on the socket;
@whack that's how it should work generally for wire protocols!
@dotstdy @whack well that makes pretty significant assumptions on byte ordering, alignment/padding on both ends; not to mention that, if untrusted, subsequent validation means that you read each struct member after copying anyways, there's no advantage anymore
@funkylab @whack endinanness is a problem if for some reason you care about that in the year 2k26, the rest isn't an issue in practice so long as you're paying attention to what goes in the structs. (i.e don't put a bool in there, manually pad to alignment)
@funkylab @whack to be clear it's not an optimization or large improvement to do it that way (unless it's a format designed for loading in-place, not applicable for a wire format mostly), I just don't think it's particularly bad either. Mid-parse validation can also be a pain so I like that separate anyway personally, but both approaches are workable.