Tim wrote a fast msgpack implementation in luajit as well:

https://github.com/creationix/msgpack-lua

On Fri, Jul 17, 2015, at 05:03 PM, Wes Chow wrote:
>
> Hm interesting, that might be what I want to use. I’m building a
> custom network messaging system at the moment and basically want to be
> sending datagrams over tcp. I was shooting for the most basic strategy
> of sending a uint32 of data size, and then a sequence of bytes of that
> amount of data. Buffer looks like it will work for that.
>
> Wes
>
>
>> On Jul 17, 2015, at 4:56 PM, Tim Caswell <[email protected]> wrote:
>>
>> By the way, there is a built-in Buffer class in luvit that ports most
>> the node.js Buffer methods including read/write of integers of
>> various sizes.  It works on mutable buffers instead of strings, but
>> the buffers should convert to strings properly when passing them to
>> libuv APIs.
>>
>> On Fri, Jul 17, 2015 at 3:29 PM, Wes Chow <[email protected]> wrote:
>>> write32 is perfect for my needs, thanks, and I was about to look for
>>> a msgpack implementation for luvit too!
>>>
>>> Wes
>>>
>>>
>>>> On Jul 17, 2015, at 4:20 PM, Tim Caswell <[email protected]>
>>>> wrote:
>>>>
>>>> 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 a topic in the 
>>>> Google Groups "luvit" group.
>>>> 
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/luvit/9E6tn59BNf0/unsubscribe.
>>>> 
To unsubscribe from this group and all its topics, 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.
>>  
>>  
>> -- 
>> 
You received this message because you are subscribed to a topic in the Google 
Groups "luvit" group.
>> 
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/luvit/9E6tn59BNf0/unsubscribe.
>> 
To unsubscribe from this group and all its topics, 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.
 

-- 
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.

Reply via email to