[erlang-questions] Difference between erl_receive and erl_receive_msg

Robert Raschke <>
Thu Feb 27 19:11:03 CET 2014


>From memory, I think your interpretation is correct. The _msg function
expects an Erlang message from the distribution layer, not just a simple
binary term. For that you'd need to promote your "simple" C code to be a
proper C node. That's not too difficult and brings further benefits, like
being able to rpc into Erlang from C.

Robby
 On Feb 27, 2014 4:13 PM, "Alexander Klein" <> wrote:

> Hello,
>
> today I tried to connect Erlang to a C-backend I'm just writing:
>
> On the Erlang-side I create a port ...
>
> Port=open_port({spawn,"./a.out"},[binary,nouse_stdio,{packet,4}]).
>
> ... to which I can send some data ...
>
> port_command(Port,term_to_binary(120)).
>
> ... and decode the data on the C-side with:
>
>         status = erl_receive ( 3, buffer, BUFFER );
>         /* a few lines snipped */
>         input = erl_decode ( buffer );
>
> This approach works quite well, so far.
>
> Trying to decode with erl_receive_msg, however, never worked, since this
> function would throw an error immediately.
>
> On the other hand, the latter is the method used in the example on page
> 343 of the book by Cesarini & Thompson.
>
> The only thing that's different to the example is the fact that I don't do
> any of the erl_connect...-stuff used there, because the backend isn't
> supposed to be used by any other nodes, anyway.
>
> What am I missing?
>
> Kind regards,
>
>         Alex
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140227/9f09f233/attachment.html>


More information about the erlang-questions mailing list