<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 10/18/2012 08:18 AM, Yash Ganthe wrote:
<blockquote
cite="mid:CALPMVvPWVGEtTURxm0NO_5aCHfZKdbGS8PLf55AmF1qR053cYA@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
<div>Hi,</div>
<div><br>
</div>
<div>From the erlang docs, the method for sending data to a C
program is:<br>
</div>
receive<br>
{call, Caller, Msg} -><br>
Port ! {self(), {command, encode(Msg)}},<br>
receive<br>
{Port, {data, Data}} -><br>
Caller ! {complex, decode(Data)}<br>
end,<br>
loop(Port);<br>
<br>
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". <br>
<br>
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?<br>
<br>
Thanks,<br>
Yash<br>
<br>
</blockquote>
Yes, but you often have to be careful of the types you use. You
probably don't ever want to try to create an anonymous erlang
function in C code that is called by Erlang code, after the data is
received within the Erlang node. If you want a consistent framework
for bidirectional integration (using Erlang ports) with C/Erlang
(including C++, Java, Python, and Ruby, currently), you might want
to try a project I have here: <a class="moz-txt-link-freetext" href="http://cloudi.org">http://cloudi.org</a><br>
<br>
<br>
<br>
</body>
</html>