koneu wrote: > On July 16, 2014 3:28:44 PM CEST, Markus Teich <[email protected]> > wrote: > > *w = ntohs(hdr[9]); > > *h = ntohs(hdr[11]); > > This will pass a char to ntohs; expanding it to a uint16_t, instead of passing > ntohs two bytes from the header.
Heyho, of course you are right. ntohs(hdr[9] << 8 | hdr[10]) or uint16_t *tw = hdr+9; *w = ntohs(*tw); should work. > The proper way would involve some pointer casting or a header struct. With a struct you get alignment issues, especially with the 9 byte magic, which aligns to nothing but 1 byte boundaries. --Markus
