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

Torben Hoffmann torben.lehoff@REDACTED
Sat Jun 5 23:35:58 CEST 2010


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 <pablo.platt@REDACTED> 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
>
>
>
>




-- 
http://www.linkedin.com/in/torbenhoffmann


More information about the erlang-questions mailing list