Hello,<br><br><div><span class="gmail_quote">On 12/13/06, <b class="gmail_sendername">Joost Yervante Damad</b> <<a href="mailto:joost.damad@siemens.com">joost.damad@siemens.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The problem I have is that almost all solutions to this "initial" problem<br>require me to tell one of the parties the node name of the other party.<br>However I'd rather have the JInterface node not know the other node and have
<br>the erlang node discover that the JInterface node is connected to the erlang<br>cluster in a dynamic "triggered" way. One of the problem is that the<br>JInterface node has no access to "globally registered" names. At least not
<br>without again first knowing the other node by name.<br></blockquote></div><br>The version of jinterface used in the Erlide project (<a href="http://erlide.sf.net">erlide.sf.net</a>) contains a method to query the epmd server for all the registered node names.
<br><br>The relevant code in the OtpEpmd class is (exception handling removed, code is in <a href="https://svn.sourceforge.net/svnroot/erlide/trunk/org.erlide.jinterface/src/com/ericsson/otp/erlang/OtpEpmd.java">https://svn.sourceforge.net/svnroot/erlide/trunk/org.erlide.jinterface/src/com/ericsson/otp/erlang/OtpEpmd.java
</a>):<br><br> public static String[] lookupNames() throws IOException {<br> Socket s = null;<br><br> try {<br> final OtpOutputStream obuf = new OtpOutputStream();<br> s = new Socket(
InetAddress.getLocalHost(), epmdPort);<br><br> obuf.write2BE(1);<br> obuf.write1(names4req);<br><br> // send request<br> obuf.writeTo(s.getOutputStream());<br><br> // get reply
<br> final byte[] buffer = new byte[256];<br> final ByteArrayOutputStream out = new ByteArrayOutputStream(256);<br> while (true) {<br> final int bytesRead = s.getInputStream
().read(buffer);<br> if (bytesRead == -1) {<br> break;<br> }<br> out.write(buffer, 0, bytesRead);<br> }<br><br> final byte[] tmpbuf = out.toByteArray
();<br> final OtpInputStream ibuf = new OtpInputStream(tmpbuf);<br> ibuf.read4BE(); // read port int<br> // final int port = ibuf.read4BE();<br> // check if port = epmdPort<br><br>
final int n = tmpbuf.length;<br> final byte[] buf = new byte[n - 4];<br> System.arraycopy(tmpbuf, 4, buf, 0, n - 4);<br> final String all = new String(buf);<br> return
all.split("\n");<br><br> } catch (final IOException e) {<br> } catch (final OtpErlangDecodeException e) {<br> }<br> }<br><br><br>best regards,<br>Vlad<br><br>