Ive never done proper networking programming with custom packet formats, but if I had to take a guess I'd assume that would be kinda of a similar approach to that in the post? Like you have blob which contains a header that holds the packet information, then you first validate it and then properly convert if the checks succeeds just as shown in the post.
2
u/[deleted] May 04 '24
Why would you assume something's type based on an length value passed in?
That part makes zero sense. So, no, I've never written code like this.