c - raw socket. ip header when to use hton -


i new raw socket, , playing around ip header. noticed ip->ip_hl = sizeof(struct ip) >> 2 //works fine; ip->ip_hl = hton(sizeof(struct ip) >> 2) //will not work;

what dont understand why not convert numbers network order instead of host order in case? what's general rule judge when use network order/host order?

thanks

htons 16-bit values. htonl 32-bit values. hton (no suffix), i'm not sure exists.

the header length occupies 1 byte (actually part of 1 byte). don't need flip bytes right form. accordingly, there no macro htons or htonl 8-bit values.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -