The libuv bindings assume all input is a lua string since lua strings are binary safe (they are just arrays of 8-bit data, nothing more).
If you want to send the single int8_t 25, you can do it with "\25" or "\x19" or string.char(25). If you want larger integers you can either encode them by hand using the bit library or use luajit's ffi structs. For example, here is encoding a 32-bit integer as 4 bytes https://github.com/creationix/msgpack-lua/blob/master/msgpack.lua#L27-L33 On Fri, Jul 17, 2015 at 2:29 PM, Wes Chow <[email protected]> wrote: > I'm writing some networking code and would like to send an int as a > sequence of binary bytes (not as a string). A socket:write(25) call appears > to send the string '25'. In regular Lua I would use the struct module to > convert 25 into bytes and then send that, however it seems as if many of > the standard libraries don't exist with luvit. What's a poor engineer to do? > > Thanks, > Wes > > -- > You received this message because you are subscribed to the Google Groups > "luvit" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "luvit" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
