From: Dave Burt Date: 2007-06-23T11:40:12+09:00 Subject: Re: ruby equivalent of htons or htonl akbarhome wrote: > I try to port this c code: > *(uint16_t *)(ptr+FSP_OFFSET_KEY)=htons(p->key); > *(uint16_t *)(ptr+FSP_OFFSET_SEQ)=htons(p->seq); > *(uint16_t *)(ptr+FSP_OFFSET_LEN)=htons(p->len); > *(uint32_t *)(ptr+FSP_OFFSET_POS)=htonl(p->pos); > > About uint16_t, I have bit-struct library. But htons messed up my > head. > > I found this link: > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/18681 We would still do htons() and hotnl() the same way. Obviously we don't have uint16_t in Ruby, and we do struct a bit differently; what are you actually trying to do? Cheers, Dave