tags:

views:

184

answers:

2

Is there a way to query the name table that epmd daemon manages?

The nodes() function isn't very helpful on that front.

NOTE: I am looking for an API aside from parsing the output generated through stdout.

+3  A: 

To query nodes visible for epmd, call:

EpmdModule = net_kernel:epmd_module().  % erl_epmd by default
EpmdModule:names().

To get a list of connected nodes and their ports:

erlang:system_info(dist).
erlang:system_info(dist_ctrl).

The first call returns you the table in a crash dump format. If you are interested in acquiring the actual ports, use the second one.

Zed
Is this supposed to work with nodes with short-names? That's mostly what I use and I don't get the expected results.
jldupont
Make sure the nodes are connected, e.g. call net_adm:ping(mynode@localhost). Works for me.
Zed
I should have been more explicit: I do not want to have to explicitly "connect" the nodes. I just want to know which nodes are reachable within the confines of a "short-name domain".
jldupont
Sorry, your example with nodes() confused me on what you meant... I added the calls you need on top of the answer.
Zed
Marvelous! Thanks again Zed!
jldupont
@zed: you rock!
jldupont
+2  A: 

You get the same answer as Zed's code by doing:

net_adm:names()

I don't know if that is a more standard way of doing it or not.

Rob Charlton
@rob charlton: Thanks!
jldupont