When creating an OtpNode instance what kind of node is this? Is it like an erl -sname xxx or like an elr -name xxx ?
Asked
Active
Viewed 859 times
3
-
Are you referring to OTP node? – jldupont Oct 20 '09 at 10:42
-
I mean when I do: OtpNode node = new OtpNode(nodeName, cookie) then this is equivalent to creating an erlang node with -sname nodeName or with -name nodeName? – Paralife Oct 20 '09 at 13:25
2 Answers
2
It is working as "-sname". At least according to the following example.
TryOTP.java (imports are omitted on purpose)
public class TryOTP {
public void start() {
OtpNode node = null;
try {
node = new OtpNode("javambox@localhost", "zed"); // name, cookie
} catch (IOException ex) {
System.exit(-1);
}
System.out.println("Connected to epmd...");
if (node.ping("shell@localhost", 2000)) {
System.out.println("shell@localhost is up.");
} else {
System.out.println("shell@localhost is down");
}
OtpMbox mbox = node.createMbox("mbox");
while (true) {
OtpErlangObject o = null;
try {
o = mbox.receive();
} catch (OtpErlangDecodeException ex) {
System.out.println("Received message could not be decoded: " + ex);
continue;
} catch (OtpErlangExit ex) {
System.out.println("Remote pid " + ex.pid() + " has terminated.");
continue;
}
System.out.println("Received: " + o);
}
}
public static void main(String[] args)
{
System.getProperties().setProperty("OtpConnection.trace", "3");
new TryOTP().start();
}
}
Running the Erlang shell:
erl -sname shell@localhost -setcookie zed
(shell@localhost)1> net_adm:ping(javambox@localhost).
pong
(shell@localhost)2> {mbox, javambox@localhost} ! hello.
hello

Zed
- 57,028
- 9
- 76
- 100
-
Thanks. So if I suppose that if i do OtpNode("javaMbox@myhost.mydomain.com", "cookie") then it would be equivalent to -name. Well, I doesnt. If i start erl -name the two of them do not work. In fact java node still thinks it is an "sname" node. How can I make java OtpNode instance behave as an erl -name node? – Paralife Oct 21 '09 at 09:07
1
From the Java code you can connect to Erlang nodes started with both -name and -sname. It is only in the other direction that it's tricky (and I don't have the answer to that). So if you can do the connection from the Java side, then the problem is solved.

Vlad Dumitrescu
- 931
- 5
- 11