[erlang-questions] Can Ports be used for initiating calls to Erlang?

Yash Ganthe yashgt@REDACTED
Thu Oct 18 17:18:01 CEST 2012


Hi,

>From the erlang docs, the method for sending data to a C program is:
receive
{call, Caller, Msg} ->
Port ! {self(), {command, encode(Msg)}},
receive
{Port, {data, Data}} ->
Caller ! {complex, decode(Data)}
end,
loop(Port);

This means a message sent to the Port with "command" goes to the STDIN of
the C prog and the C prog responds with "data".

Is it possible and customary to use the same mechanism to have a C program
INITIATE calls to an Erlang module? Is it common to have C programs invoke
Erlang functions by sending a "data" on STDOUT and waiting for the response
on STDIN?

Thanks,
Yash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121018/d92725e7/attachment.htm>


More information about the erlang-questions mailing list