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

Robert Raschke rtrlists@REDACTED
Thu Oct 18 18:55:58 CEST 2012


It can depends a bit on your use case. While you can use stdio as the
comms, another way is to"upgrade"your port program into node using ei for C
or jinterface for Java.

Robby
 On Oct 18, 2012 4:18 PM, "Yash Ganthe" <yashgt@REDACTED> wrote:

> 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
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121018/2993b892/attachment.htm>


More information about the erlang-questions mailing list