Re: FFI and endian conversion

  • From: Luke Gorrie <luke@xxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 26 Jul 2012 15:08:45 +0200

On 25 July 2012 13:18, Justin Cormack <justin@xxxxxxxxxxxxxxxxxxxxx> wrote:

> I have been using ffi metatypes to add these accessors so you do not need
> to explicitly convert. Eg so x.sin_port is in network byte order but you
> can use x.port to get the host byte order using the metatable.
> You could also hide any alignment issues using metatables.
I'd be interested to see example code for this. (I'm a Lua newbie so it's
not completely obvious how you're doing this.)

Other related posts: