<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1528" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New" size=2>Here is an
addition to OtpEpmd.java, allowing programs to retrieve the list of registered
nodes.</FONT></SPAN></DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New" size=2>best
regards,</FONT></SPAN></DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2>Vlad</FONT></SPAN></DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2> public static String[] lookupNames() throws
IOException<BR>
{<BR> Socket s =
null;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2>
try<BR>
{<BR>
OtpOutputStream obuf = new
OtpOutputStream();<BR>
s = new Socket(InetAddress.getLocalHost(), epmdPort);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2>
obuf.write2BE(1);<BR>
obuf.write1(names4req);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2> //
send
request<BR>
obuf.writeTo(s.getOutputStream());</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2> if
(traceLevel >=
traceThreshold)<BR>
System.out.println("-> NAMES (r4) ");</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2> // get
reply<BR>
byte[] tmpbuf = new
byte[1024];<BR>
int n = s.getInputStream().read(tmpbuf);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2> if (n
< 0)<BR>
{<BR>
// this was an r3 node => not a failure
(yet)<BR>
if (s !=
null)<BR>
s.close();<BR>
throw new IOException("Nameserver not responding when requesting
names");<BR>
}</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2>
OtpInputStream ibuf = new OtpInputStream(tmpbuf);</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2> int
port =
ibuf.read4BE();<BR>
byte[] buf = new
byte[n-4];<BR>
System.arraycopy(tmpbuf, 4, buf, 0,
n-4);<BR>
String all = new
String(buf);<BR>
return
all.split("\n");<BR>
<BR> } catch (IOException
e)<BR>
{<BR> // epmd
closed the connection =
fail<BR> if (s
!=
null)<BR>
s.close();<BR>
if (traceLevel >=
traceThreshold)<BR>
System.out.println("<- (no
response)");<BR>
throw new IOException("Nameserver not responding when requesting
names");<BR> } catch
(OtpErlangDecodeException e)<BR>
{<BR> if (s !=
null)<BR>
s.close();<BR>
if (traceLevel >=
traceThreshold)<BR>
System.out.println("<- (invalid
response)");<BR>
throw new IOException("Nameserver not responding when requesting
names");<BR> }<BR>
}</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=465365811-15032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV></BODY></HTML>