[erlang-questions] Difference between erl_receive and erl_receive_msg

Alexander Klein xelalex_maker@REDACTED
Thu Feb 27 14:54:28 CET 2014


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



More information about the erlang-questions mailing list