Erlang: is there an API to 'epmd'?

2019-04-08 16:01发布

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.

标签: erlang
2条回答
Animai°情兽
2楼-- · 2019-04-08 16:55

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.

查看更多
老娘就宠你
3楼-- · 2019-04-08 17:00

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.

查看更多
登录 后发表回答