[erlang-questions] Naive questions about jinterface
Dmitrii Dimandt
dmitriid@REDACTED
Tue Aug 12 09:07:18 CEST 2008
On Aug 11, 2008, at 5:14 PM, Dennis Byrne wrote:
>
> Hi Dmitrii,
>
> The approach taken in the article is one of two ways to go about
> using jinterface. The other way is covered pretty well by these
> slides from this years' Erlang eXchange conference. This approach
> is much more mailbox centric.
>
> http://people.apache.org/~dennisbyrne/erlang_exchange/erlang_exchange_jinterface.ppt
Yup, I've seen this one as well. It's excellent in showing how you can
implement erlang's features using jinterface, but I'm still a bit
lost :) (yeah, yeah, I'm stupid and stupid enough to admit it :) )
So, I've created this java class:
import com.ericsson.otp.erlang.*;
public class ServerNode {
public static void main (String[] _args) throws Exception{
OtpNode self = new OtpNode("jinode@REDACTED", "cookie");
OtpMbox mbox = self.createMbox("jimbox");
OtpErlangObject o;
OtpErlangTuple msg;
OtpErlangPid from;
while (true) {
try {
o = mbox.receive();
if (o instanceof OtpErlangTuple) {
msg = (OtpErlangTuple)o;
from = (OtpErlangPid)(msg.elementAt(0));
mbox.send(from,msg.elementAt(1));
}
}catch (Exception e) {
System.out.println("" + e);
}
}
}
}
Now it is my understanding that if I start erl with:
erl -name clientnode@REDACTED -setcookie cookie
I can send messages to the Java node like this:
{echo, 'jinode@REDACTED'} ! {self(), msg}
However, this message never reaches the java node :( Even though
net_adm:ping('jinode@REDACTED') returns pong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080812/c83120cc/attachment.htm>
More information about the erlang-questions
mailing list