[erlang-questions] JInterface and node discovery

Siddharth Pareek <>
Thu Jan 18 15:50:01 CET 2007


hi ,
     I had gone through the previous answers with the same subject as mentioned above but my problem is a little bit different .
        I too wana know the nodes which are in cluster  ..but the cluster are on the different machines. 
 
      Executing the following code will return me only the nodes that are clustered on a single machine . Is there any way by which i can get the names of all the nodes that are clustered on other machine along with my machine nodes.


private static final int epmdPort = 4369;
private static final byte names4req = (byte) 110;
private static int traceLevel = 0;
private static final int traceThreshold = 4;


Socket s = null;

try {
final OtpOutputStream obuf = new OtpOutputStream();
s = new Socket(InetAddress.getLocalHost(), epmdPort);
obuf.write2BE(1);
obuf.write1(names4req);
// send request
obuf.writeTo(s.getOutputStream());
if (traceLevel >= traceThreshold) {
System.out.println("-> NAMES (r4) ");

// get reply
final byte[] buffer = new byte[256];
final ByteArrayOutputStream out = new ByteArrayOutputStream(256);
while (true) {
final int bytesRead = s.getInputStream().read(buffer);

if (bytesRead == -1) {
break;
}
out.write(buffer, 0, bytesRead);
}

final byte[] tmpbuf = out.toByteArray();
final OtpInputStream ibuf = new OtpInputStream(tmpbuf);
ibuf.read4BE(); // read port int
final int n = tmpbuf.length;
final byte[] buf = new byte[n - 4];
System.arraycopy(tmpbuf, 4, buf, 0, n - 4);
final String all = new String(buf);

return all.split("\n"); 


Thanks and Regards,
Siddharth Pareek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070118/3c56572c/attachment.html>


More information about the erlang-questions mailing list