[erlang-questions] what about little-endians?

Tony Rogvall <>
Sat Mar 13 00:26:45 CET 2010


erts/emulator/beam/packet_parser.c

update the packet_get_length function with the new packet types.
suggestion TCP_PB_LE2, TCP_PB_LE4  (-1 is obviously not needed unless you mean to reverse the bits ;-)

You should then be able to use the bif erlang:decode_packet/3 to test your extension like:

erlang:decode_packet(2, <<0,2, 1, 2, 3>>, []).
{ok,<<1,2>>,<<3>>}

/Tony


On 12 mar 2010, at 20.03, Camilo Cerchiari wrote:

> hello all,
> 
> i'm working on a system that receives socket messages with a 4 bytes header
> containing an unsigned integer representing the size in bytes of the rest of
> the message.
> 
> everything would be just fine if the header was in big-endian byte order, as
> i could set inet:setopts(Socket, [{active,true},{packet,4}]) and receive the
> socket packets as erlang messages.
> 
> unfortunately the header is in little-endian byte order. so...  why only
> big-endian is available for inet:setops?  are there any plans for including
> support for little-endians like my clients?  if no plans...  i would like to
> add that -1, -2, -4 packet options in the code myself.  could you give me
> some tips to get started with that?  in a first quick search i didn't get to
> the part of the code that controls that.
> 
> thanks in advance,
> salutes,
> Camilo



More information about the erlang-questions mailing list