[erlang-questions] Decoding Erlang Messages Sent Over TCP With EI

Steve Vinoski <>
Sun Jan 2 20:48:41 CET 2011


On Sun, Jan 2, 2011 at 2:29 PM, John Koenig <> wrote:
> I am currently porting a server process (written in C) to ei, which used to interact with an
> erlang process via the older erl_interface.  I am able to get the the two sides talking over a
> localhost TCP socket, but I am having trouble decoding the tuples sent to the C based server.
>
> Tuples are being sent from an interactive erlang session as follows:
>
> {any, } ! {tuple1, typle2, []}
>
> When the message is received in the C based server via ei_receive,  however,
> ei_decode_tuple_header returns non-zero and I am unable to proceed further.  Calling
> ei_get_type on the buffer results in 'p' which, according to ei.h, corresponds to
> ERL_NEW_FUN_EXT.  Why is this failing and why is this tuple being reported as an
> ERL_NEW_FUN_EXT?
>
> The only example I have seen thus far
> (http://www.trapexit.org/How_to_use_ei_to_marshal_binary_terms_in_port_programs) uses ei
> stdin/stdout, can ei be used over a TCP socket at all?

Ei most definitely works over TCP. Can you post more of your decoding
code? Hard to tell what's going on from what you've told us so far,
but p is value 112 and there are a couple instances of that value in
the encoded form of your tuple above, so you're likely just decoding
at the wrong offset.

--steve


More information about the erlang-questions mailing list