[erlang-questions] {packet, PacketType} for little-signed packets

Dmitry Belyaev <>
Mon Jun 7 10:48:35 CEST 2010


There is implementation on BSON in emongo. You can look at 
http://bitbucket.org/rumataestor/emongo
It is not necessary to use {packet, ...} at all.

Dmitry Belyaev


On 06/06/2010 02:17 AM, Pablo Platt wrote:
> Hi Torben
>
> I'm implementing mongodbwire protocol http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol
> The first 4 bytes in each message are int32 of the "total message size, including the 4 bytes of length"
> and all data is little-endian: "Note that like BSON documents, all data in the mongo wire protocol is  little-endian."
>
> Is it possible to patch gen_tcp to support BSON?
> Is there a simpler solution?
>
>
>
>
> ________________________________
> From: Torben Hoffmann<>
> To: Pablo Platt<>; erlang-questions<>
> Sent: Sun, June 6, 2010 12:35:58 AM
> Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets
>
> Hi Pablo,
>
> I don't quite understand what your issue is, but it might be due to my lack
> of understanding of the gen_tcp details. If not I think you should rephrase
> your question.
>
> Anyway, I have a piece of advice based on your code sniplet.
>
> If you are defining the protocol yourself I would strongly suggest that you
> make Length equal to the size of the Message since it makes decoding a lot
> easier. I have dealt with Q.SIG and there the length in the PDU also depends
> on the size of the header which forces one to do the decoding in two steps
> instead of having the option to do it in one step in the function clause
> pattern match.
>
> Cheers,
> Torben
>
> On Sat, Jun 5, 2010 at 17:39, Pablo Platt<>  wrote:
>
>    
>> Hi
>>
>> Is there a way I can handle {packet, PacketType} for little-endian where
>> Packet =<<Length:32/little-signed,Message/binary>>
>> Length=4+byte_size(Message)
>>
>> I currently handle it manually but it'll be nice if gen_tcp could handle it
>> for me the way {packet, PacketType}
>> works for big-endian byte order.
>>
>> Thanks
>>
>>
>>
>>
>>      
>
>
>
>    


More information about the erlang-questions mailing list